There is no single best setting
Portraits do not have one correct depth of field. A headshot with a thin zone of focus can look striking, while a full-length portrait with a little more depth may give a better sense of the person and the place. The best choice depends on what you want the viewer to notice and how much of the person needs to be sharp.
As a starting point, many portrait photographers use a moderate to wide aperture, roughly f/2 to f/4, for a single person. Adjust from there. The aperture, the distance to the subject and the lens all change the result, so check the image on screen.
Headshots and close portraits
For a headshot or a tight close-up, the zone of focus is thin even at moderate apertures, because the subject is close. A wide aperture such as f/2 or f/2.8 can make the background very soft. If the eyes are sharp and the ears or hair fall outside the zone, that is often acceptable.
Be careful with very wide apertures at close range. The zone can be so thin that only part of the face is sharp. Stop down a little, to f/4 or f/5.6, if you want more of the face in focus.
Half-body and full-length portraits
When the subject is farther from the camera, the zone of focus is deeper at the same aperture. A half-body or full-length portrait may need a wider aperture to blur the background, or a longer lens and a greater distance from the subject.
A full-length portrait at f/8 may look sharp everywhere, including a busy background. That can be a good choice for environmental portraits, where the place matters. If you want the background softer, open the aperture or move the subject away from it.
Groups and couples
Groups need more depth. People at different distances from the camera will not all be sharp at a wide aperture. For a couple standing side by side, f/4 to f/5.6 is often enough. For a larger group, f/8 or narrower may be needed, depending on how far the people stretch from front to back.
If the group is spread out, try stepping back and using a longer lens. A longer lens from farther away keeps the group’s depth roughly the same at the same aperture, but it also makes the background look closer to the people, so check how the setting looks on screen.
Focus on the eyes
Whatever depth you choose, the eyes should usually be sharp. In a portrait, sharp eyes make the image feel right even when other parts are soft.
Use single-point autofocus when you can, and place the focus point on the eye closest to the camera. If you are using a wide aperture, small focus errors matter more because the zone is thin. Take several shots, and check each one at full size.
Background choice and distance
The background plays a large part in how a portrait looks. A busy background can distract, but a soft one can help the subject stand out. Distance is the key tool here.
Put the subject some distance in front of the background, and then open the aperture. The background falls further out of focus and becomes softer. If the subject stands right against a wall, the wall will still be fairly sharp, even at a wide aperture.
Lens choice for portraits
Longer lenses are popular for portraits, often in the range of about 85mm to 135mm on full-frame cameras. They let you stand farther back, and at a fixed framing they give a similar depth of field to a wider lens at the same aperture, but they also compress the background and make it look closer to the subject. Shorter lenses can work well for environmental portraits, where you want more of the setting.
Choosing the lens is partly about how you want to work. A longer lens gives you space from the subject. A shorter lens brings you closer and includes more of the surroundings.
Checking the result on screen
Look at the image at full size, not just the thumbnail. Check the eyes first, then the hair and face, then the background. If the eyes are soft, focus was off. If the background is distracting, change the distance or the angle. If the face is only partly sharp, stop down a little.
For more on how aperture and distance control the sharp zone, see the article on how to get shallow depth of field.