How do I fix a "water hammer" problem?
This normally happens near quick-acting valves in your plumbing system, like those used in a clothes washing machine.  Those valves are opened by a solenoid and get slammed shut by water pressure, and all that water coming to such an abrupt stop can rattle already-loose pipes, cause them to become loose, or in the worst case damage them over time and cause leaks.  That's why water hammer arrestors are commonly installed near washing machine outlets (it may be required by code, I'm not sure).  They look like this:



They work by maintaining a reservoir of air inside that vertical tube.  When the column of water is stopped abruptly by a valve, the air acts as a cushion, compressing so that the water can slow down more gradually and impart less inertial force to your pipes.

These are fairly easy to install even for someone with no plumbing experience.  I believe the one pictured is designed to be mounted inline with a sink or toilet connection, and they also make models with standard garden hose style threads for a washer connection.  You shouldn't need to install these at every fixture; one set (hot and cold) for each bathroom/kitchen should be plenty.

Since your problem seems to occur on (relatively) slower-acting valves that shouldn't be generating an unacceptable amount of water hammer, you may also just have a section of pipe that's not mounted properly.  If you're only noticing the banging sound in one area, it may be possible to open up the wall there and install some pipe clamps to keep things from moving around and making noise.  This would be a more difficult job than installing arrestors (but potentially cheaper if you do it yourself).