Rubbing the balloon on your hair creates static electricity and that static electricity causes static cling and that's why the balloon will stick to your hair.
You can rub a balloon on carpet and the balloon will stick to your hair or other things as well due to static cling.
I used to rub balloons on my hair and our carpet a lot as a kid.
It was great fun.