I found this article:
"How to Clean Ketchup, Pasta Sauce, or Barbecue Sauce off a Carpet"
and this is another from Good Housekeeping:
1. Mix one tablespoon of liquid hand dishwashing detergent with two cups of cool water.
2. Using a clean white cloth, sponge the stain with the detergent solution.
3. Blot until the liquid is absorbed.
4. If the stain remains, mix one tablespoon of ammonia (Caution: Never mix chlorine bleach and ammonia - the resulting fumes are hazardous) with 1/2 cup of cool water.
5. Sponge the stain with the ammonia solution.
6. Blot until the liquid is absorbed.
7. Sponge with cold water and blot dry to remove the ammonia solution.
For more on stain removal, see Good Housekeeping's Stain Rescue
Here is another method I found on eHow.com:
Mix a little dish soap with 2 cups of cold water. Wet the cloth with the mixture. Dab at the spaghetti sauce stain until it starts to fade; this may take more than one attempt.
Mix together 1 tsp. of ammonia and 1/2 cup of cold water; soak a sponge in the solution. Gently dab the spaghetti sauce stain with the solution to remove the stain.
Sprinkle a generous amount of baking soda onto the spaghetti sauce stain; spray some hot water on top. Scrub the stain with a brush; leave it to dry. Vacuum the spot once it is dry.
Pour some salt onto the spaghetti sauce stain. Rub it in with a stiff brush. Pour club soda on top of the salt. Once dry, vacuum the area and dab with warm water.
Borrow or hire a carpet steam cleaner to clean the spaghetti sauce stain. For extra tough spaghetti sauce stains, you might want to spray some ammonia and water mixed together on the stain before using the carpet cleaner. If this fails, consider hiring a professional carpet cleaning company