Shut off the gas flow to the water heater by locating the shutoff valve on the gas line going to the water heater. Turn the handle on the shutoff valve so it is perpendicular to the gas line.
Locate the pilot light access panel, which is at the bottom front of your A.O. Smith water heater. Remove the retaining hex nuts using a nut driver, and set the panel out of the way.
Identify the thermocouple, which is a device that has one end connected to the pilot light and the other end connected to the gas line that feeds the pilot light.
Unscrew the fittings on both ends of the thermocouple using an adjustable wrench. Turn the fittings counterclockwise to loosen them, and remove the thermocouple.
Thread the fitting on the larger end of the new thermocouple onto the gas line where you removed the old one. Thread the other end onto the pilot light assembly. Tighten both fittings using the adjustable wrench. Restore the gas supply, and replace the access panel once you have lit the pilot light.