Pilllows, memory foam ones included, eventually get stinky or otherwise need cleaned. Turns out, you aren't supposed to wash them though. The tag on a memory foam pillow just says, "Spot clean, do not place in washing machine or dryer. Use mild detergent, no chlorine bleach. Let air dry away from direct sunlight and heat." Well, you can't spot clean an odor...
So I blatantly ignore the part about sunlight. When the memory foam itself manages to get stinky, the only thing to do is either take a chance and gently wash it in water or lay it out in the sun. I don't want to risk damaging it by squishing and squeezing it to hand wash it (I read plenty of articles warning against that), nor do I really have the patience to hand wash and then wait for it to air dry anyway, so I opt for an hour or two in the sunshine. It's way less maintenance and you only do it as needed. Be sure to set a timer so you don't leave it out there all day because as I understand it, too much time in the sun will eventually damage the memory foam. Besides, it shouldn't take more than a few hours to be deodorized (and supposedly even sanitized thanks to those uv rays).
I lay out a small cloth on a bush and lay the pillow on that. After an hour I flip it over. One more hour and I bring it inside.
The only thing you can throw in the washing machine is the zippered cover, so definitely use a pillow case in addition to that. That way you have two washable layers. (If you sweat a lot or have oilier hair/skin maybe even use two pillowcases.) Change the pillow case(s) weekly, and wash the zipper cover as frequently as you like. I'd suggest weekly or monthly.
You can even buy extra zipper covers for about $10 so you can change them weekly with your pillowcase without having to run the washer every time.