Alot of toddlers do this type of behaviour. However, if that behaviour continues and is accompanied by other behaviours such as scratching at his face, spinning, flapping his hands etc, as well as difficulties with speech (either talking or understanding what is said to him), and problems with playing with other children or not appearing interested in other children, as well as appearing deaf or covering their ears - then you need to get an opinion from his paediatrician. The behaviours i've mentioned are common with being on the autistic spectrum. Alot of the above behaviours can be typical, but children grow out of them. At the age of 2+ children start to develop their social side. Just make sure you keep all his health check appointments and that he is developing as his peers and is joining in with them and is chatting and not just using speech to get his needs met.
Re-direct him as best you can.
Believe is or not, it is quite normal for toddlers to bang their head when frustrated or tired. My daughter did the same. I would just tell her over and over to not bang her head against the wall because she would hurt herself. I was beginning to wonder if she even felt pain and my uncle asked me the question also. Eventually, it stopped. I just tried to redirect her. Get him interested in something else. You could get his attention also by singing or dancing and clapping your hands (sometimes that works).