Many odours can be eliminated by soaking the troublesome area with baking soda. One of the tricks to make the baking soda the most effective, such as to remove pet urine from a rug, is to add water to the baking soda to make a paste. Work the paste into the fibres of the rug.
Then cover it all with plastic wrap to prevent it from drying out quickly. Leave it about a day, remove the plastic, remove most of the soda and let it dry. Then vacuum it up. A treatment or two will often remove both stains and odours.
Even more effective than the good old baking soda for removing odours are cleaners with enzymes in them, often sold at pet stores. The enzymes are actually small bacteria that eat the organic material causing the odours.