Clean up as much spaghetti sauce as you can with a spoon. Be careful not to spread the sauce to unstained areas of the carpet.
Mix 2 cups cold water with 1 tablespoon liquid dishwashing detergent. Dip a white cloth in the solution and wring it out so it's not dripping. Patiently blot at the stain until the liquid in the sauce is absorbed and the stain is gone, or until the remaining discoloration cannot be removed. Don't get the stain too wet, and don't scrub it or you will embed the stain deeper into the fibers.
Dip a new white cloth into plain cold water and wring it out. Dab at the stain to remove the detergent. Rinse and repeat a couple of times to ensure all the detergent is gone.
Apply baking soda to the area if the carpet is still discolored. This discoloration is probably caused by the oil in the sauce. Allow it to sit for 15 minutes, then gently vacuum to remove the baking soda.
Repeat Step 3 to remove all traces of baking soda.
Dab any remaining traces of discoloration with a white cloth dipped in dry cleaning solvent, then repeat Step 3 again to remove the solvent.