The technical term is "Pinking", the knock sensor is a Piezo crystal device which picks up the pinking frequency before the human ear can detect it. The sensor sends the signal to the ecu like Deck says and the ecu then decides whether to retard the ignition or not. It is required due to the weak mixtures modern engines use and varying quality and RON rating of petrol throughout the vehicles anticipated operating area. Because it is a Piezo crystal device it is tuned by the torque of the centre fixing bolt, so if you ever fit a new sensor make sure the mating surface is clean and that you torque the fixing bolt up to the correct torque.