Run a cycle without clothes, without detergent and with chlorox or vinegar. You may have to do this more than once.
Always leave the lid up or the door open so that the machine dries out between uses.
After reading other wonderful responses I remembered that if the space between the drum and the outside case needs cleaning, you can remove the back of the washer to clean it. Be sure to unplug the washer first.
You can also clean out the dryer this way. Sometimes lint builds up inside the dryer outside the drum and this can be a fire hazard.
My Dad was an appliance repairman and did these things for me. He said it was safe as long as the plug is pulled. I think a gas dryer would also require that the gas be shut off but I don't really know about that.
You can call an appliance repair shop and ask them about this. My Dad told people how to care for their appliances themselves. He had enough work fixing breakdowns. :):)