Add 1/4 cup of baking soda along with your regular laundry detergent. Baking soda helps remove laundry odors, making your clothes smell fresh and clean.
Add a fabric softener to the appropriate dispenser, using the amount specified on the label. Fabric softeners typically have a pleasant scent. Alternatively, use 1/4 cup of vinegar instead of a commercial fabric softener. Vinegar also softens clothes and absorbs odors. Don't use vinegar if you are using chlorine bleach, since the two together can emit toxic vapors.
Leave the door slightly open when you're not using the washer to help prevent musty odors. If you have small children, this may not be a safe option for your family.
Wash a load of laundry using chlorine bleach once every five or six loads to remove musty or mildew smells.