A knocking sound coming from your engine when you accelerate could be caused by excessive heat and pressure creating a "detonation" in the engine. If this problem continues, you could severely damage your head gasket. Fortunately, most vehicles are equipped with a knock sensor that automatically adjusts the timing to prevent detonation from occurring. If you hear knocking, you may want to immediately test your knock sensor to make sure it is working.
Park your car on a level surface and open the bonnet. Make sure the engine is in park and the emergency brake is on. Start the car.
Locate the knock sensor on your engine manifold. The knock sensor will be located beneath the intake manifold just about at the middle of the engine. The intake manifold is where the exhaust pipes connect to the engine. It can be located on either side of the engine. The knock sensor will have a wiring harness coming out of the top and be set into the engine block.
Strike the intake manifold above the knock sensor with a crescent wrench, do not hit the sensor itself. Listen to the sound your engine makes, you should hear a small change to the sound of the engine; this is the timing being adjusted by the knock sensor to accommodate the detonation you just created by hitting the manifold. If you do not hear the engine make that adjustment, your knock sensor is not working.
If your car is constantly under load (by towing or driving in mountainous conditions), try using a higher octane gas to prevent detonation from occurring.
Never hit the sensor itself. The internal electronics of a knock sensor can be easily damaged and are expensive to replace.