The engine’s knock sensor (or sensors) detects preignition and detonation, potentially damaging forms of abnormal combustion. Though full-blown knocking and pinging are audible to the human ear ...
The knocking is a warning sign that there could be (or already is) a serious engine repair in your future ... thanks to the current state of anti-knock sensor technology, it can be an issue ...