Mainly, don't have petted him from a lamb. :/. It's a very common story!
I wish I could make it a law that people not pet the face of sheep or cattle, it just engenders butting and ramming. We now say, "Scritch under the chin, or on the neck behind the ears, or not at all. Never ever ever on the face or front of the poll (bit between the ears.)". And we don't hand feed tups either, ever.
He needs to learn respect, but it's much harder to do now. He needs to be in no doubt that in any argument, you will win.
Are you able to catch him, tip him up and hold him until you decide it's time he got up? If so, it may work to do that every time he butts. Other people have talked about whacking them across the face with a stick or a piece of alkathene pipe, but even if you're prepared to do that, I suspect it's as likely to result in a fight which you might not win, or an ongoing battle where he looks for opportunities to beat you, as to teach him that you are the boss.
However, if you can't get his respect, then it's off to the abattoir for him, before he hurts someone. There are lots of people on this forum have been injured, some of them badly, by rams. Don't join them.