There are a number of reasons that gnats will fly around a person's head, including the smell of a shampoo. Gnats are attracted to fruit smells, and a number of shampoo products have fruit fragrance added to the product.
Gnats are also attracted to moisture, light and fungus. People tend to notice gnats in well-lit areas due to the bugs being attracted to bright lights. Gnats also tend to spend time flying in the air at about the average height of a human. Sweat and dirt also attracts gnats and can be the cause of the bugs flying around a person's head.