Objects are usually neutral, meaning they're neither positively nor negatively charged. When a balloon is rubbed against your hair, however, it becomes charged. Molecules from your hair temporarily form a bond with molecules in the balloon by sharing electrons. Some of the electrons from your hair defect to the balloon. These new electrons temporarily leave the balloon with an electron overload, meaning it's now negatively charged because it has more negatively charged electrons than positively charged protons.
By the same token, when you rub a balloon over your hair and the electrons in your hair molecules defect to the balloon, they leave your hair with fewer electrons than it started out with, meaning that your hair now has more positively charged protons than negatively charged electrons — resulting in a positive charge.
As the old saying goes, "opposites attract." Oppositely charged objects attract one another, so when the negatively charged balloon moves away from your positively charged hair, your hair tries to follow and "stands up." Fortunately, all of this is temporary. Your hair soon goes back to normal.
If you rub the balloon over your hair hard enough and create enough charge, you may be able to create enough static electricity to see tiny sparks, suggests the Physics Educational Outreach at the University of Houston website. The best chance of seeing it is to stand in front of a mirror in a dark room. The sparks won't be strong enough to hurt you, the site notes.