My dd has banged her head or pulled her own hair, intenetionally, on occasion, since about 15-16 months I'd say. This could be precipitated by being tired, bored, hungry, wanting attention, or any combination thereof.
I treat it like I would treat her hitting anyone else. I tell her to be gentle with herself, that we don't hit anyone including ourselves, that it hurts. Then of course I redirect her attention to a positive activity or take care of any needs she might have (hunger, overtired, etc.). I try not to give it too much attention, but I am not going to ignore her while she hurts herself either.
I think, like anything else, it is a sensation and they want to know what it feels like.