Young dogs usually learn bite inhibition while playing with other dogs.
When dogs play, they nip and mouth each other.
Occasionally, a dog nips his or her playmate too hard, causing the victim to yelp and, usually, stop playing.
This should startle your dog, causing him or her to momentarily stop nipping and mouthing.