my son hits himself in the head?

hes 16 months old and when he gets in trouble or i say "no". he hits himself in the head. just hits himself over and over and it breaks my heart. so i hold him and kiss him and he stops but it really breaks my heart. why does he do it? im a sahm so it isn't a learned behavior.