The iPhone is an extremely complicated device that actively generates and dissipates heat as a natural byproduct of its normal operation. This is especially apparent when you connect the device to a charger. When you do so, you begin a complex set of electrical and chemical reactions that give off heat as a waste product. Heat waste is also created by other components when you use the iPhone, and a basic understanding of these processes can help you keep the device in a safe temperature range.
The iPhone battery is composed of lithium ions in a sodium solution that react with metal electrodes. When you charge the battery, these ions move from one side to the other. This reaction creates heat. A little bit of heat is normal, but the iPhone should never become so hot as to become painful to the touch. In such a case, there are likely other factors involved that are still within your control.
The iPhone contains a processor that runs its operating system and carries out the complex computations required to run applications and even rudimentary functions such as receiving calls. Every calculation the iPhone makes requires energy, and some of this energy is wasted in the form of heat. Thus, if you use the iPhone extensively while charging it, you run the risk of making it even hotter than it would have been otherwise and pushing it toward a critical temperature.
Using iPhone While Charging
"Apps" are any application that come with the iPhone or that you download from the Apple Store. You can use apps while the iPhone is charging, but if you run too many of them while the device is charging, you will increase its thermal load. If you drive its thermal load too high and too often, you will shorten the life of the battery and you can even damage the iPhone's delicate internal components.
Maximum Temperature Envelope
The phone was designed so that it would generate and dispel a certain amount of heat. If the iPhone becomes too hot, you can actually receive an error message that says "iPhone needs to cool down before you can use it." This error message appears once the iPhone crosses a critical temperature threshold. You can prevent this from occurring by using your iPhone for only the most basic functions when it is charging. You may want to limit yourself to one app and taking and receiving calls, for instance.