To add to Fred's answer: in Sifra (to Num. 5:18, the same verse that the Gemara cites) R. Yishmael finds support for the idea that unmarried virgins don't need to cover their hair in II Sam. 13:19, ותקח תמר אפר על ראשה, by explaining אפר as "a scarf" - i.e., we see that Tamar began covering her head with one only after she was violated. (As the commentary Meir Ayin there notes, R. Yishmael may have arrived at this understanding - instead of the standard translation of אפר as "ashes" - because the usual verb that would go with that is ותעל, "she cast up," or ותזרק, "she threw.")
The Lubavitcher Rebbe zt"l points out (Igros Kodesh, vol. 11, letter 3592) that since the verse in the Torah is talking about a married woman, there's nothing to tell us that it should be extended to an unmarried one. As for a deeper reason behind the distinction, he suggests that since the requirement that women cover their hair is a consequence of Chavah's having misled her husband Adam into sinning (Eruvin 100b), then it need not apply to a girl who has never had a husband.