The answer to this question is: it depends. Some toothpastes contain ingredients which can help get rid of pimples, while others do not, and in some cases they can actually irritate the skin. Given that there are numerous other acne remedies available, toothpaste should really only be viewed as a last resort. It also usually requires an overnight treatment to work effectively, so don't depend on toothpaste for emergent zit crises.
There are two ways in which toothpaste can work to get rid of pimples. In the first sense, toothpaste can act like a mask, drawing impurities out of the skin; it may also dry the skin slightly as it does so, which can reduce the size of a pimple. In addition, some toothpastes contain menthol or alcohol, two compounds which can dry the skin, although they can make your skin too dry, which is not desired.
If you want to use toothpaste to get rid of pimples, look for a true toothpaste, not a gel, and if you can, find one with minimal additives. Natural or organic toothpastes are a good bet, since they usually have a short ingredient list. Apply a small dab to the acne spot in question, leave it on overnight, and rinse in the morning. Your mileage may vary, depending on the toothpaste, your skin type, and the pimple.
If you want to get rid of pimples, there are a number of home remedies as well as over the counter medications which can help; if you have a severe case which has developed into acne, you may want to consult a doctor for stronger medications. Avoid popping pimples, no matter how tempting it is, because you can actually make the situation worse by causing a deep infection. If a pimple gets truly upsetting for you, head to a cosmetician who specializes in extractions; he or she has received special training in handling pimples, blackheads, and other blemishes. A dermatologist may also be willing to pop it for you.
Some home remedies to get rid of pimples include aspirin, which can be ground into a paste with water and applied overnight, as well as applications of lime or lemon juice and potato wedges. Over the counter medications can also be used to target trouble spots. More importantly, keep your face clean and grease-free, and use water based moisturizers for your skin care to help avoid the development of pimples in the first place.