When the heater was replaced, the water was shut off for some period and water drained. An air pocket probably developed in the line near near the toilet so a water column can slam against pipes when the toilet valve shuts completely. If there is a hand valve below the toilet tank to shut the water off, you might turn the valve closed and then open it just a bit to let the water enter the tank slowly over a longer period of time than it does now. The slower velocity may stop the bang. If it does or it does not, a plumber asked to specifically stop this from occuring (without closing the valve) would look at the lines and tank mechanism to stop the noise.