Fortunately, faces have some easily recognisable features that cameras can lock on to; a pair of eyes, nose, and a mouth. By being able to detect a face in the scene, the camera can concentrate its autofocus on that person's face to ensure it is the primary subject in focus within the image. More sophisticated implementations can also link up to scene-recognition algorithms and optimise the exposure for the subject's face.
Once a face has been detected, the system will track that face as best it can. If the person turns away, detection lock will be lost, though some camera manufacturers have enhanced the detection capability to maintain a lock even when the subject has turned to the extent that only one eye remains visible. Some face detection modes can lock onto several faces at once, in which case the face that is used as the primary subject of focus will usually be based on which is closest or most prominent, though sometimes you can override this by selecting a face manually. If several faces are detected at once, not all of them will necessarily be in focus.
Face recognition is an enhanced form of face detection. Instead of simply letting the camera recognise any face in the crowd, you can configure the camera to recognise a particular person's face and use this as the focal point. To do this, you simply take a portrait shot of the person you want the camera to recognise and save it in the recognition system's memory. You can usually program in several identities at once. Some camera manufacturers are even starting to supply software that reads the embedded identity data saved in the image file. This could be a useful tool when searching images for a particular person who was recognised by the camera at the time the picture was taken.