The water heater thermocouple is a device that monitors temperatures in the water heater to determine whether it needs to heat up or turn off the heat. It is comprised of two different types of metal, which react differently to heat and expand at different rates, signaling to the water heater when to turn on or off. If the water heater is not working properly (not heating up), you should test the thermocouple to determine if that is the problem.
How to Test
You can purchase thermocouple testers at hardware stores, they are inexpensive and can save you a trip to the store. However, many hardware stores will test them for you and can help you select the correct replacement part if the thermocouple is bad. Some thermocouples have two different types of metal wires twisted together, and should be tested with a multitester. The reading on the multitester should be close to zero ohms. You can test it further by connecting it to a thermometer and ensuring it is reading hot and cold correctly.
Replacing the Thermocouple
Turn off the gas to the water heater and remove the thermocouple from the water heater. The thermocouple will be located right next to the pilot. Take the thermocouple to the store and replace if needed. Install the new thermocouple, turn on the gas, and light the pilot.