Wash your clothing items as soon as possible once they are dirty. Leaving dirty clothes around for extended periods of time invites the growth of mold and mildew.
Store dirty clothes in a cool, dry area. Dry dirty clothes that are wet even if you can't wash them for a while. You can't realistically wash every piece of dirty clothing right away. If you throw the clothing items down in a damp, warm environment, they are likely to acquire a moldy smell.
Treat clothing items that smell moldy by soaking them in white vinegar before you wash them. Allow them to soak for 20 to 30 minutes.
Dry clothing outside on a clothesline if possible. Sunlight also helps to kill mold spores.