Musty odors—bad smells caused by the growth of mold and mildew—can happen to any object stored in a dark, damp place for too long. This includes precious keepsakes like dolls and other toys, items that can't be tossed in the washer and may be difficult to thoroughly clean without risking damage. When this happens, choose one of several gentler ways to wash and deodorize your doll, depending on what it's made of and how severe the problem is.
The first thing to do is to get your doll out of the area where it's been stored. Chances are, this area is the source of the musty smell (caused by growth of things like mold and mildew) and is probably infested with a smell of its own, especially if it's a small space. Just getting the doll out of here and letting it air out for a few days may be enough to remove the bulk of the smell.
If not, try bringing the doll outside where the air is more open. Choose a sunny day to let the doll sit in the sun, as the sunlight will help to kill odor-causing growth.
For dolls that still smell bad, try placing the doll for a few days in a clean, dry and relatively closed container, but this time, store it with some substances that will absorb the unpleasant odor or replace it. This can include dishes of baking soda or vinegar, vanilla extract, clean cat litter (designed to absorb odor) or coffee grounds.
For times when basic odor-removing steps aren't enough, more involved cleaning methods are required. The best way to go about this will depend on your doll and what it's made of—for example, a cloth doll may need to be hand washed in a gentle hand soap (add about a quarter cup of baking soda to a basin as well for some extra odor removing). If this still doesn't work, consider sending the doll to a dry-cleaner, but take care if it's fragile or very old.
Dolls that are a combination of porcelain and cloth can be hand washed, but sending them to a dry-cleaner is a little tricky. You may have to consider dismantling the doll temporarily (or having a skilled sewer do it for you); carefully remove the head and limbs with a seam ripper, then sew the body closed again before sending it to be cleaned (you may also consider replacing the body entirely if it's of a simple construction). The porcelain pieces themselves won't hold smell and should be fine with a simple hand wash.
Other types of dolls made of porous materials may smell but be more difficult to wash, such as dolls made from wicker or dried corn husks. These fragile dolls probably can't be washed, so try a product specially designed for removing must smells from things that can't be washed, such as OdorXit CLO2, a spray often used for deodorizing the pages of musty books.