Most hot water tank replacements should be done around the 10-year mark. At that point, while your system may still last a few more years, they may no longer be covered under warranty and will often decline in performance, reliability and efficiency.
An aging hot water tank that is performing poorly is likely to cost you in the form of higher utility bills.
Tankless water heaters tend to last longer than hot water tanks and can be expected to last 15-20 years before they need to be replaced.