One of the things that drives me mad is unbound/uncovered hair in historical Movies and TV shows. Historically women wore some kind of head covering at least in Europe and America. When did the practice die out.
First we need to explore why the cap was worn in the first place (at least in the majority of Euro-centric cultures). Up until recently women didn't go out in pubic with their hair unfinished. In the 1950s even, setting the hair with curls was the standard finished appearance. The easiest way to style the hair, even today, is to throw it up in a bun or pony-tail. Prior styles also encouraged caps as a simple way to finish off this hairstyle in a fashionable, but quick, manner.
Secondly, it keeps the hair clean. In a world where fires are burning every day in the house for cooking, cleaning, and heat the house has smoke which permeates the hair. Outside, most streets are unpaved and therefore the air is dusty. Add in dirt, leaves, bugs, etc and keeping your hair protected from the outside becomes very important in keeping it clean. In the 18th century men kept their heads covered by a working cap or hat for the same reasons.
So, why would such a useful item fall out of fashion? The need for having finished hair certainly didn't change. And while some time periods have easier hairstyles to achieve, that varies widely throughout the 19th century. Even in industrial situations of the mid 20th century, where styled hair wasn't practical, women would put their hair up in kerchiefs, keeping them clean in the same way. One thing that does change is our methods of washing. In the 18th century hair was often cleaned by use of pomade and powder. Think of pomade, made with animal fats, as the conditioner replacing necessary oils for healthy hair. It also contains useful things like clove oil, a natural pest repellant. The powder works like a dry shampoo. Combing this through the hair, making sure to reach the scalp to avoid build up, cleans and conditions. It also makes the hair fuller and easier to style. As we move through the 19th century, views on health and the methods to achieve it change. While washing as we are used to doesn't become common until the 20th century (daily hair washing later in the century), there are still many recommendations on how to wash the hair to clean it. Being encouraged to regularly strip the dirt from the hair by way of washing is becoming more common.
By the 1860s fashionable caps are often sheer and made of netting, not meant to keep the hair clean. Caps are, however, still being used by women in jobs associated with being clean. Such as nurses, maids, and kitchen workers. Loose, but styled hair, we consider clean, finished, and beautiful today. But we still don't want untamed hair in those situations. Capped hair is seen on women in industrial situations or even workhouses into the 20th century. They need to keep not only their hair protected from the dirt and grime of their work, but potentially keep the work clean of their hair.
However, the invention of the middle class in the 19th century puts many women back in the home rather than working. The home itself becomes cleaner. Industrial inventions to make the housework easier and cleaner occur, like coal and gas ovens (1833 and 1826 patents).This likely had an effect on the fashionable classes and their reasons to keep their hair covered for cleanliness.
All of this goes into the fact that fashion changes. Some time periods have the most fashionable wearing hair pieces or nothing at all. Caps go in and out of fashion, though hair is always finished (often up off the neck). The practical usage of caps does change from being an everyday necessity to a working garment, especially with the further separation of work and home spheres in the 19th century. Caps never really die out, they just cease to be fashionable.