For a young puppy who does not know any commands yet, when they start to bite, put a toy in their mouth instead. When they reach for a toy, praise them. If they bite you by accident, yelp loudly and disengage with play-time by standing up and going about your "boring human business." You can try playing again after they have calmed down.
(If the puppy refuses to accept that play time is over and follows you still trying to play, completely ignore them. If they try to bite or jump to get your attention, put them in "time out" in a pen or gated room where you can keep an eye on them, but they are not with you.)
If your puppy is starting to know commands like "sit" or anything else, that can be a great way to rein in the playtime and bring it under your control. A dog who is focused on sitting cannot bite you. More play is a great reward, often better even than treats. You can also teach your puppy a command like "fetch" and when they get too rough, ask them to fetch a toy. Again, a puppy with a toy in its mouth cannot bite.