In the bathroom and areas where the tile gets wet use penetrating grout sealers. They use a water base that penetrates the grout.
In the kitchen and other surfaces that don't have standing water often, use a membrane forming grout sealer.
To apply grout sealer, first, tape any cabinets or baseboards to avoid staining them. Use a foam paint brush or small paint roller and apply the sealer. Avoid getting the sealer on the tiles. If you do use a rag and wipe it off quickly as once the sealer dries you'll be left with a foggy film that's almost impossible to remove.
After the first coat, wait about 10-15 minutes, allowing the sealer to soak in (some products may need longer). Apply a second coat and then let it dry. For bathrooms and showers wait 24-48 hours to use it, the rest of the house the sealer should be good after about 3-4 hours.
To extend the life of the seal, avoid/or minimize the use of harsh cleaners throughout the year.