My guess would be that it is something to do with osmosis; your body fluids are concentrated solutions, tapwater is a very dilute solution; meaning that water is going to be taken up by your exposed tissues, possibly quite rapidly and this might cause stimulation of nerve ends. Come to think of it, the nervous system itself operates on a delicate balance of salts and ions; introducing weak solutions to it (or near to it) might directly stimulate nerves.
Mangetout is correct. Your cells have a semipermeable membrane surrounding them. Inside cells, electrolytes are at a certain concentration. When exposed to fluid that is hypotonic (lower amounts of these electrolytes) there is movement of h2o across the membrane, and cells swell/burst.
When they talk about “Normal Saline” it is a 0.9% solution of NaCl which is isotonic.
Distilled water would be even more hypotonic than tap water.
I’ve found that open cuts and so forth sting when you have a combination of:
cold water (colder than the skin temp anyways)
dirty salty sweat mixing in.
The second one would describe both of your scenarios; wetting hands/hair before washing them (I’m guessing they were dirty right?) for a few seconds dissolves and spreads around whatever is on the skin around the cut into it. When you lick a cut your tongue is the same temp, doesn’t dribble all over the place and splash stuff around, plus you’ve got another sense (taste) to distract you and you might not notice the stinging as much.