Fast fix: For the first line of defense, dab the stain with water immediately. If you have access to some detergent, even better. Spot-treat.
Home remedy: Pretreat the stain with liquid laundry detergent or a prewash stain remover, like Tide to Go. On light-colored fabrics, consider spraying on some hydrogen peroxide, which acts as a mild bleach. Then machine wash, using a detergent and a bleach that are safe for the fabric.