The inside of your washing machine is a haven for mold, which likes the dank, wet and dark conditions. The best way to clean a washer, according to Washing Machine Wizard, is with bleach.
Add 1 cup liquid bleach to the washer and run the machine on the hot cycle. The combination of hot water and bleach kills bacteria and removes stains. If the problem persists, run the machine through again on hot with 1 cup distilled white vinegar. Wipe down the outside of the machine with warm water and a damp cloth.
Whirlpool makes a product called Nu Fresh, which it claims cleans washers and recommends using on Whirlpool brand washing machines. Similar products for cleaning washing machines include Affresh and products from Smelly Washer.
Do not use vinegar in your washing machine, unless it's recommended or approved by the manufacturer. The acidity of the vinegar may damage the inside of the washer.