Both of the Knock Sensors are located in the intake valley underneath the intake manifold. It Takes 2.6 hours to do both and both of them I would do, so you don't have to do the job twice, ( like buying 1 sock at a time ). Also, ONLY Use factory parts, after market Knock Sensors have a poor record.
The knock sensor does retard the timing so the engine will not produce NOx, which is a dirty and poisonous Emission. When the Knock Sensor codes is set, the timing does roll back and stay retarded until the problem is resolved. Be sure to inspect the problem, because maybe your Knock Sensor code is a signal that your engine is pinging. If your engine runs a little hot or your EGR system is plugged or not working ( if equipped ) then the Knock Sensor may be telling the truth.