The petcock is a small fuel valve which is bolted to the side or underneath the tank. You will notice it will have a couple of different settings, such as ON, OFF, RES, or PRI. These are to allow the user to decide when and how the gas in the tank is delivered to the carburetors. It is set up like this mainly for a simple way of helping the rider determine when he is low on gas. Most riders ride with their petcock always on ON. When he or she feels the bike running out of gas, switch to RES, and then you know the bike has about another half gallon before it runs out of fuel, so its time to fill up.
These things get as nasty as the tank gets, and since the petcock has small passageways and rubber diaphragms, it can fail. Fortunately a cleaning usually gets it back in operation, and even still they are cheap to replace if need be.