A great way of deodorizing carpet is to use baking soda.
Take a box of baking soda and sprinkle it all over the carpet and make sure you cover the entire carpet and then let it sit overnight or while gone to work to allow it time to absorb the odors.
Baking soda is great at absorbing odors so after it sits the baking soda should absorb all the odors from the carpet.
Then Vacuum the baking soda out of the carpet the next day or when you get home from work.
After that get a carpet cleaner machine and mix some vinegar with the water and run it over the carpet and the vinegar will help naturally clean the carpet and remove any additional odors in the carpet.
Or you can also use regular carpet cleaner instead of the vinegar if you want too.