Gentle but firm voice commands.
He either doesn't like too much petting, in which case, let him come to you and watch his body language, when his changes, move your hand.
Or he sees it as playing. In which case, play with him more and praise him while you do but gently but firmly tell him no when he goes to bite you.
You can also take less notice of him when he is doing that so he learns it's not a good way of getting attention, don't be tempted to move him round in case he thinks it's a game and does it to prompt play and attention.
It might take a bit of time and patience.