If the child has been taught correctly (and doesn't have a developmental or learning disability), by age 5 or so. Children with atypical issues (whether formally diagnosed or not) need to be given more time -- into their teens or twenties for some.
Unfortunately, many young parents these days do not understand how to parent and so do not explicitly teach their children these social interaction skills. As my dh says, "You need to buy a license to raise chickens, but you don't need a license to raise children."