Since your questions is tagged with OpenCV, I will assume that you are looking for a solution within this library.
The first step is to find the faces. For this, use one of the cascade object detectors that are available: either the Viola-Jones one or the LBP one. OpenCV comes with cascades trained for face detection for each of these detectors.
Then, it depends if getting a bounding box is enough or not.
If you need something more accurate, then you can:
- [coarse face] use a skin color detector inside the face bounding box to get a finer face estimate, binarize the image and finally close the face shape using morphological filtering;
- [fine face contour] use something like a grabcut procedure to get a pixel-accurate contour. You can initialize the grabcut with borders of the bounding box as background and center part of the bounding box as foreground.