A knock sensor is responsible for detecting abnormal combustion noises or engine knocks. It sends signals to the engine control unit (ECU) to adjust the ignition timing and prevent engine damage.