The medical term for hair graying is canities. Hair turns gray (or white) when your hair follicles stop creating melanin. Melanin is the substance that gives your skin and hair color.
When we start to go grey depends a lot on genetics. Your first grey hairs usually appear anywhere between your twenties and fifties. For men, grey hairs normally start at the temples and sideburns.