Pheromones are an often unsung element of human attraction. Released in the form of unique chemical secretions, their biological purpose is to trigger a social response between one person and another through an appeal to the sense of smell. In other words, we all emit a unique scent that some people are attracted to on a pure, biological level. Since it's been said that most pheromones are released through the scalp and other hair follicles, it stands to reason that they would have some effect on the men who consciously or subconsciously seek to sniff a girl's hair. Thus, when a guy smells a girl's hair, he's smelling her every bit as much as he's enjoying the scent of her lovely locks.
He might also feel a sense of familiarity or connection depending on the scent itself. Smell is such a strong trigger of memory that a boy might just feel good when he smells a girl's hair, even if the element of attraction is missing. Maybe her hair reminds him of a loved one or an ex, or a happy memory that he can't quite place but can still recall on some level when it's triggered by scent.
Generally speaking though, it does depend on the individual guy. Some men find it arousing, some men can't resist the way a girl's hair feels and smells, and others just find the smell pleasant.