Agar is used in cosmetic formulations as a gelling agent to create stable and consistent textures in products like creams, lotions, and masks. It helps to improve the viscosity and texture of the formulation while also providing hydration and soothing benefits for the skin.