I am assuming that you mean knocking noise and not horrendous bangs that sounds like a sledge-hammer. A ticking or knocking noise can occur from the plastic plumbing vents installed walls today. As hot water runs inside the drain, the plastic expands, rubbing against wood making a ticking sound about once per second as the plastic pushes on the wood then overcomes friction. I have had this noise for 25 years.
If it is this noise, then you need to open the wall and space the plastic pipe away from the wood. If it is a heavy bang, the water heater may be making a steam pocket and collapsing steam bubbles inside the heater. Banging in the pipes from moving water would require the tap to be running to bang.