Replace it if it is leaking from the tank, if it is past 12 years and showing rust or noise, or if a repair would cost more than a third of a new unit. Otherwise, fix it and start saving for the replacement.
Get the repair quote and the replacement quote. If the repair is more than a third of a new installed unit, and the heater is past the halfway point of its typical life, replace it. If the repair is cheap and the heater is young, repair it. In the middle, think about what else is going on: a tank over living space, a house you are selling soon, or a house you will be in for 15 more years each push the answer a different way.
A like-for-like tank swap is usually a half-day job. Current code may require things the old install did not have: an expansion tank, a drain pan with a line to a drain, seismic straps, a new vent or a sediment trap on the gas line. Those add cost but they are not upsells. Switching to tankless or to a heat pump water heater is a bigger job that often involves gas line sizing, venting or a new electrical circuit, and it is worth pricing both ways. Federal and utility rebates for heat pump water heaters change often; check before you decide.
Put a pan with a drain line under the tank, or at least a leak alarm. Know where the cold-water shutoff is. Flush sediment and check the anode rod. Keep the install date and this decoder's result somewhere you will find it, because the first thing a plumber asks is how old it is.
The decoder on the home page reads the build date out of the serial number for 53 brands.
How long does a water heater last? · How long does a tankless water heater last?
Check your model and size before you buy. Amazon links are affiliate links: as an Amazon Associate I earn from qualifying purchases.
The age you just looked up is the kind of fact that gets lost. A written record of serial numbers, install dates, repairs and who did the work saves the next owner, inspector or insurer from guessing.
A lifetime logbook for the house, organized by system, with room for serial numbers, install dates, repairs and contractors. It stays with the house for the next owner.
Galvanized, polybutylene, cast iron and the sewer line: what fails, what it costs, what insurance won't cover and how to decide.
A buyer's guide to older homes: wiring, pipes, lead, asbestos, insurance refusals and what the repairs actually cost.
Book links are Amazon affiliate links.