We have had good luck with white vinegar/water followed by baking soda/peroxide/dish soap. It's a bit of a process but I find it works really well and is cheap to boot. I would hesitate to use heat on your carpets as you can set the stain/smell in the carpets.
For a fresh pee stain:
1. Absorb as much pee as you can. We use paper towels and stand on them (cheap flip flops protect your feet and wash easily) to blot as much pee up as possible. Layer a few towels down, step on the towels to blot. Repeat with fresh towels until you no longer pick up wet.
For an old pee stain:
1. Find the spot(s) either using your nose or a black light. My husband takes one for the team and prowls around on his hands and knees for nose duty.
After drying or finding the spot(s):
2. Mix a half and half white vingear and water solution. I typically mix 1 cup with 1 cup but it depends on the stain size and/or the number of stains. Liberally douse the stain. I mean really soak in the vinegar solution. You want to get down through the carpet and into the padding, maybe even into the subflooring if possible. Also make sure you are soaking an area larger than the actual stain so you get all of it. This step neutralizes the odor so be generous with the vinegar solution.
3. After drenching the spot, work the vinegar solution into the carpet with a scrub brush.
4. Blot the vinegar solution as before. A wet/dry shop vac is handy too for this blotting and the vac won't stink since the vinegar neutralizes the pee.
5. Allow the spot to dry or nearly dry naturally. (With the wet/dry shop vac you can move directly to the next step as it is dry enough.)
6. When the area is nearly dry or dried completely, sprinkle baking soda over the spot. You don't have to put a pile on the spot but a generous layer is the goal.
7. Mix a half cup 3% hydrogen peroxide with a teaspoon of plain dishwashing detergent. We put the solution in a spray bottle for ease of use. (We use Dawn because it is on hand. Do not use a caustic detergent. Also do not use a hydrogen peroxide greater than 3% or it may bleach your carpets.)
8. Apply the peroxide solution over the baking soda. Work the peroxide solution into the baking soda and the carpet with your hand or a scrub brush.
9. Allow the spot to dry completely without blotting.
10. Once the spot is dry, vacuum up the baking soda residue.
This has also worked on a poo stain. Just clean up the solids and proceed. Good luck.