If your pet has had an accident, scrub the area with club soda as soon as possible and let it dry. Then sprinkle the area with baking soda and let it stand to help control odors. After an hour or so, vacuum the rug thoroughly.
If a stain or discoloration remains, apply a generous amount of lemon juice to the area; let it soak for about 15 to 30 minutes. When the stain is removed, rinse the area well and blot it thoroughly. Another remedy to try is a paste made with lemon juice and cream of tartar, followed by the same rinsing and blotting technique.
After the stain removal, deodorize if necessary by rinsing the area with a vinegar and water solution. It's important to remove the odor -- doing so helps give your pet the signal that they should not do the same thing in that spot again.
If the accident was fairly small, say, a simple spot of urine on a rug, it can be cleaned up by applying straight vinegar to the area with a sponge or rag. Let it dry, then spend some time giving your pet a refresher course in potty training.