Dogs pant to cool off when they are feeling hot.  When our body temperature gets too high, we sweat.  Evaporation of sweat from the skin takes up a lot of heat, and helps cool the body.  But dogs are almost completely covered with hair, and have every few sweat glands.

They can’t keep cool by sweating.  Instead, a dog pants.  It sticks out its tongue and breathes rapidly.  By panting, a dog moves air back and forth over the moist tissues of its mouth and tongue.  As the moisture evaporates, body heat is carried away, and the dog feels cooler.–Dick Rogers