Inside your mouth are taste receptors. They pick up on the senses of salty, bitter, sweet, sour, and umami (which seems to be activated by monosodium glutamate (MSG)).
giving us the sensation of taste. In the papillae, wrapped around the tastebuds, there are also a set of neurons that send information about temperature, and pain. These are the receptors we are going to concentrate on.
Now say you take a big bite into a jalepeno pepper. Why does it feel hot ? The reason is that hot peppers contain a molecule called capsaicin. This molecule basically excites a small set of the pain sensors which also happen to respond to hot temperatures. So basically your brain gets the signal that there is something hot/painful there, even though there really isn't. Other types of spices such as say menthol found in peppermint, for example trigger a different set of receptors, ones that send signals for pain and cold.
One way to think about it is that the temperature receptors are like a lock, and that hot stuff is the key. When the key meets the lock, the neuron carries a signal to the brain. Now say we have don't have the key but we have something that is shaped pretty close to it. We will still be able to open the lock, thus tricking the lock into thinking we have the key. This is different from say, smashing the lock open with a hammer. In other words, though there is a chemical setting off these receptors, it isn't actually a chemical burn or actual damage that causes the burning/painful sensation.
One final note, which is partially from personal experience : Capsaicin triggers a type of receptor which can be found anywhere on the body. If you've ever cut really hot peppers, you might notice your hands starting to tingle/burn slightly. This is the capsaicin activating the same type of receptor, only on your hands. It is also a good reason to wear gloves when handling hot peppers. In addition, this is why it is a bad idea to rub your eyes after handling peppers (ouch !).
If you want more detailed answers, check out :
For more about a new way of measuring how hot something is :