A pimple is a result of a blockage of the skin's pore. See Acne vulgaris.
Inside the pore are sebaceous glands which produce sticky sebum. When the outer layers of skin shed (as it does continuously), the dead skin cells left behind may become 'glued' together by the sticky sebum. This causes a blockage in the pore, especially when the skin becomes thicker at puberty. The sebaceous glands produce more sebum which builds up behind the blockage, and this sebum harbours various bacteria including the species Propionibacterium acnes. Since the body's natural defence against bacteria is primarily phagocytes (white blood cells), these rush to the site behind the blockage (where the bacteria are). This is what gives some pimples the 'whiteheads' (unless the Phagocytes are deeper in the skin, which means you can't see the 'white' caused by them). The white blood cells then destroy (by phagocytosis) the bacteria to prevent infection. The pain one may feel when a pimple is present is caused by the widening of skin around the white blood cells.Common over-the-counter medications for pimples are Benzoyl peroxide and/or salicylic acid. Both medications can be found in many creams and gels used to treat acne through topical application. Both medications help skin slough off easier, which helps to remove bacteria faster. A regimen of keeping the affected skin area clean plus the regular application of these topical medications is usually enough to keep acne under control, if not at bay altogether. 1-2% of the population is allergic to Benzoyl peroxide treatments. Severe acne usually indicates the necessity of prescription medication to treat pimples. Prescription medications used to treat acne include isotretinoin, which is a retinoid. Historically, antibiotics such as tetracyclines and erythromycin were prescribed. While they were more effective than topical applications of benzoyl peroxide, the bacteria eventually grew resistant to the antibiotics and the treatments became less and less effective. Also, antibiotics had more side effects than topical applications (erythromycin can cause stomach cramps)