Kids explore all kinds of interactions with the world during their first couple of years. And they keep doing what seems to "work." Many, like hitting (self, head, or others), kicking, are disturbing to parents and tend to get strong reactions.
Kids crave attention and notice, even if it's negative, though they prefer positive and happy attention. So, other than a calm statement like "No hitting, please," and perhaps putting him in his playpen or just walking away, do your best to ignore the behavior. Also, make a point of noticing things you like or appreciate or find amusing, and make sure he knows you've noticed. An approving word, a touch, a smile or giggle. He'll like that attention and start focusing more on the behaviors you like.