I use Nature's Miracle, an enzyme cleaner. You can get it at Petsmart, Petco, etc.

I pour it onto the carpet, let it soak through and leave it to dry. If any pee soaked into the padding, you have to make sure you get the solution down into the padding. I also clean my carpets every 3 or 4 months.