Most knocks come from the ignition or the injector nailing. Fuel injectors can also cause a knocking noise, especially in older diesel vehicles.
Not all knocks are harmful, so it is important to determine the cause quickly so that if there is a serious issue the vehicle owner can attend to it. Many new vehicles have mechanisms to boost pressure, adjust timing and detect knocking in the engine. One example is the Automatic Performance Control feature that is present in the turbocharged Saab H engines. This works to decrease boost pressure so that the engine no longer has a reason to knock.