If the urine stain is fresh, cleaning the urine up as fast as possible removes the smell. If the urine has dried into the carpet, use a deodorizing cleaner suitable for the type of carpeting, and follow up with an enzymatic cleaner if necessary.
If the stain is still damp, use clean towels or paper towels to blot up as much urine as possible. Do not rub at the stain, as this works the urine and its smell deeper into the carpet fibers. If a test in an inconspicuous area indicates that hydrogen peroxide does not stain the carpet, pour hydrogen peroxide on the stained area, let it soak for an hour, then blot it up. Repeat the process using a 1:1 mix of white vinegar and water, and let it sit for 30 to 60 minutes before blotting. If smell still remains, use an enzyme cleaner made for removing pet odors according to the instructions on the label.
If the stain is dry, make a paste of 1/2 cup of 3 percent hydrogen peroxide solution, 1 cup of baking soda and a few drops of dishwashing liquid. Work the paste into the stain while wearing gloves. Let the paste dry, and vacuum it up. If there is any remaining odor, sprinkle baking soda over the stain, and leave it for 24 hours before vacuuming. Alternatively, use a commercial carpet cleaner or stain remover, following the directions on the label, and follow up with a vinegar and water mix as described above or with an enzyme cleaner.
If urine has soaked into the padding or flooring underneath the carpet, removing the stained material and replacing it may be necessary. Consider hiring a professional service if this is the case or if the carpet is a valuable Oriental or wool carpet.