The answer to this question really depends on how old your puppy is.
Many dog training books advocate the infamous “Alpha roll,” where you roll the puppy over and pin him on his back. Don’t pin him… even though the mother dog may do this… WHEN she does it and HOW she does it are things that the amateur dog handler…. even sometimes the experienced handler… will never be able to replicate properly.
If the dog is really young, like 7 or 8 weeks old, you basically want to redirect the biting behavior towards a toy or chew bone. If the pup is simply in an ultra rambunctious state, put him in the crate. This is not punishment, however, it’s just confining him to an area where he can’t develop these bad behaviors. Similar to putting a baby in a crib, or a play pen.
Sometimes, you can quickly bend the lips around the teeth of the pup and say “No.”… so that the dog learns if he bites you, the response is something that doesn’t feel good. Just beware that you don’t let this turn into a game.
If the dog is a bit older, like 12 or 13 weeks, you can put a small, light pinch collar and tab (a 3/4′ leash) on the dog, and give a light (caution:light) pop on the leash. Again, the dog will not continue to do a behavior which does not feel good. This technique always works… just use common sense, read your dog, and be careful not to over-correct. But at the same time, make sure that the correction IS motivational. I.E., if the dog keeps doing the behavior, that’s usually a good sign that your correction isn’t motivational. You’ll be fine.
Most likely, depending on the dog’s age, he’ll grow out of it even if you don’t do anything. But again, this depends on the temperament and breed.