What controls it
Three things: aperture, how close you are to your subject, and focal length. A wide aperture (low f-number) and getting close both shrink the zone of sharpness; a narrow aperture (high f-number) widens it.
When to use which
Shallow depth around f/1.8 isolates a subject against a soft background. Deep depth, f/8 to f/16, keeps a landscape sharp from foreground to horizon.
See it
Example photo coming soon
Try it
Frame one subject with something in the background, then shoot it wide open and stopped down. Compare how much falls away.