1. Find the cold water inlet valve
Look at the top of the water heater tank. There are typically two pipes coming out of the top: one is the cold water inlet, feeding water into the tank, and the other is the hot water outlet, sending heated water to the rest of the house. The shutoff valve is on the cold water inlet side, usually just above where the pipe meets the tank.
2. Close the valve
Most water heaters use one of two valve types. A round handle valve closes by turning it clockwise until it stops. A lever-style ball valve closes with a quarter turn, so the handle sits perpendicular to the pipe rather than in line with it. Either way, you're looking for the point where it stops turning easily, not forcing it further.
3. Can't find it or it won't budge? Use the main shutoff
Older valves can seize up from mineral buildup, or you might not be able to locate a dedicated valve at the unit at all. In that case, your home's main water shutoff valve, usually located where the main line enters the house, near the water meter, or in a basement or crawlspace, will stop water to the entire home, including the water heater. It's worth locating this valve now, before an emergency, so you're not searching for it under pressure.
4. Expect hot water to stop
Once the cold supply is shut off, the tank can't refill, so hot water taps throughout the home will run cold or stop delivering water fairly quickly. That's expected and not a sign anything else has gone wrong. It stays that way until the unit is repaired or replaced and the water supply is restored.