In general, your dog should not bite you, even if it is just in play. You should replace your hand with a toy and let them know that they are not meant to bit you. This might be as simple as to stop playing with them as soon as they bite to let them know that it’s not appropriate, or just a firm ‘no!’ and gently putting your hand around their muzzle. However, it really depends on the individual circumstances.
I would recommend attending a dog training class to see if there are any additional behavior modifications that could be put in place to prevent this. You can also check out the main site for behavior tips here: https://www.vetbabble.com/dogs/training-and-behavior/