Not necessarily.
An engine knocks when there is too much pressure for the octane rating of the fuel or too much heat that ignites multiple flame fronts which collide in the cylinder.
Retarding the ignition timing works by reducing the time for pressures to build between the moment the mixture ignites and starts to expand and TDC.
Carbon can cause knock two ways: first, it can create hot spots that act like glow-plugs to ignite fuel at lower pressures (ie: before the spark). When that happens, the burgeoning flame fronts are fighting both each other and the piston's rise to TDC.
Second, a layer of carbon takes up space, which raises the compression pressure in the same manner as shaving the heads would.
Premium has a higher octane rating, which means it is more resistant to detonation and burns slower so it doesn't self-ignite as readily and the flame fronts don't propagate as quickly if they should ignite. Therefore the pressures don't build until the piston has passed TDC. That's why it is necessary to use premium fuel in high-compression engines -- ignition can be early enough for thorough combustion, yet pressures still remain manageable before TDC.
Besides spark advance and octane rating, knock is affected by a few other things too:
The wrong heat range plug can cause knock in the same manner as a hot carbon deposit.
A hot engine is more likely to suffer knock. Besides low coolant, a defective fan clutch, thermostat, or water pump, lime and rust deposits in the head and block can reduce heat transfer so the head temperature may be higher than the temperature gauge indicates.
Air
intake:
Cold Air Intake systems are a popular performance mod not just because cooler air is denser -- it has the potential to reduce knock. Things like stuck pre-heat valves can contribute to knock.
Lean Fuel Mixture: Lean mixtures not only burn hotter, they require less heat to auto-ignite. The system is
supposed to learn and self-adjust, but there are only a limited number of O2 sensors for all those cylinders and they adjust to the average value. Vacuum leaks or dirty/sticking fuel injectors can cause one or more cylinders to run leaner.
The EGR helps keep combustion temps down too. If the EGR valve is stuck or passages plugged, that may contribute to knock.
I already mentioned oil consumption in the previous reply -- excessive oil vapour lowers the mixture's net octane rating -- which reminds me of something that happened many years ago:
The cops busted an organized ring that was charging for disposal of industrial waste oils and disposing of it by diluting it into no-name tanker trucks of gasoline, which they then sold to small independent gas stations at a slight discount. While that possibility is rather remote, are you buying your gas from independents that have to undercut the big guys by a few cents per gallon?