A plumber will check the fuel supply or power, the burner or elements, the thermostat, the relief valve, and the tank itself, then tell you whether a part will solve it or the heater has reached the end of its life. Ask about sediment, the anode rod, and how the venting looks on a gas or oil unit.
Replacing a water heater in Massachusetts generally calls for a plumbing permit, plus a gas permit for a gas unit. In Wareham both come from the Inspectional Services Department at Memorial Town Hall, through online applications only. The inspector visits Tuesday through Thursday, booked by the license holder who pulled the permit, and the posted permit card has to be at the house.
If you're weighing a switch to a heat pump or a high-efficiency gas model, ask whether a Mass Save offer applies. Eversource and National Grid both sponsor Mass Save, and current offers are listed on its site.