Ketoconazole is an antifungal agent used both topically and orally to treat fungal infections by inhibiting ergosterol synthesis, a critical component of fungal cell membranes. While topical use is common for skin and scalp infections, oral use is limited due to potential liver toxicity. It is effective against dermatophytes, yeasts, and certain systemic fungi.