All dogs pant, even the smaller breeds like chihuahuas. They can pant whether they are healthy or sick. For your chihuahua, panting is a cooling system. Humans sweat to cool their bodies, but dogs cannot do that with their thick fur, so panting allows them to cool their bodies. Extreme heat, dehydration, stress and excercise can lead your chihuahua, and any dog, to start panting.
When dogs get overheated, they have the ability to cool their bodies by cooling the saliva and fluids in their mouths. They breathe in allowing the air to cool those fluids. This in turn cools the blood vessels in the dog's head and works to prevent heatstroke. What we see as dogs panting is really them working to get the air they need to cool down.
Much like humans, dogs need water to cool their bodies and allow them to run efficiently. They can get dehydrated just like humans do when they do not get enough water. This can cause heatstroke and vomiting. Dogs pant in order to cool their bodies and stave off dehydration until they can get some water to help cool their bodies.
Stress, emotions and fears that put a strain on a dog's body can cause dog's to lose water quickly and leave them dehydrated. It can also lead to shaking, increased heart rate and even seizures if severe enough, both of which can also lead to dehydration. This will cause excessive panting in order to not only cool down, but to calm down and reduce their heart rate.
When running around, whether playing fetch or accompanying you on your run, dog's increase their heart rate and overheat. They turn to panting to cool themselves down not only after but during exercise, much like humans sweat while exercising. When your chihuahua pants excessively, see that it has access to water in order to avoid a heatstroke.