First, the thermometer you use should be accurate, and second, it should ideally be fast.
Digital (not mercury) thermometers are recommended.
A rectal temperature is most accurate for babies under 3 to 6 months (although you can first check the temperature under the arm as a screening measure and then go for the rectal if the underarm temperature is higher than about 99 degrees F).
Over the age of 6 months, temporal artery thermometers may work well. These require a simple swipe of the thermometer probe across the forehead. An ear thermometer that fits correctly in a child's ear may also be used. Underarm (axillary) temperatures may be taken in kids of any age (as long as they stay still long enough for the thermometer to get a reading), and children 4 years and up may be able to use an oral thermometer.
For more information, check out this article in AAP News: