As he develops speaking and listening, you can tell him that it would be better if he did not hit his head. As he grows up, you can make a game of it and reward him with points, when he does not hit himself! Or you can pretend once in a way, that you are taking your hand to your head and then turn it down and laugh! Do everything in connection with changing the habit, with warmth and a sense of humour. Make up a song or a story which includes the habit, which is finally given up. Some method will evolve as you go along.