There are two conditions you don't want to hear (occur) in your engine, pre-ignition and detonation. There always seems to be confusion as to what these two very different conditions are, so we'll explain the differences.
Pre-ignition is exactly what it sounds like. During the compression stroke the air/fuel mixture ignites before the spark plug fires. This is due to a "hot spot" on the piston crown or in the combustion chamber. A hot spot is caused by a very thin metallic edge or a carbon deposit which may actually begin to glow (like a starting glow plug in a diesel engine or a glow plug in a model airplane engine). Usually what you will hear is a metallic "pinging" sound. Compression ratio and octane ratings have little to no effect on pinging, only hot spots. To eliminate pinging you need to eliminate the hot spots. To do this you'll either need to de-carbonize the piston crowns and combustion chambers, and/or slightly radius any sharp edges on the piston valve relief's or combustion chamber edges (and/or spark plug threads) within the combustion chamber.
Detonation is a botched mixture burn. When the spark plug ignites the mixture, the burning process should be smooth and relatively progressive, the pressure variance (rise and fall) looking something like a standard bell curve. For best power generation, max pressure of the burning fuel/air mixture should normally occur at about 10 degrees after TDC of the ignition stroke, which determines the amount of ignition advance your engine needs. If the air/fuel mixture doesn't burn evenly and completely, the "flame front" doesn't propagate smoothly, which normally results in pressure variations. The pressure variations can be extreme, like hitting the piston crown with a hammer. This causes shock loads to the piston crown, rings, wrist pin, and rod bearings, which are fatal to your engine.
Detonation is almost always octane related, in that higher octane gasoline's have additives to make them burn more slowly, evenly, and completely (yeah, regular burns faster than premium). However it may also occur when mixtures become too lean or when ignition timing is set too advanced. Detonation is also compression ratio related; the higher the CR, the higher the octane rating requirement to prevent detonation. This has to do with an endothermic rise, as pressure increases the temperature goes up; this is Boyle's law again from high school physics: PVT = P'V'T'. With currently available 94 octane (not motor rated) the highest practical ratio for a small six is 9.5:1 with cast iron heads, and 10:1 with our aluminum head. This is because heat plays a role, and aluminum dissipates heat better than cast iron. Note that smaller displacement engines, like a 1.8 liter 4 cyl, 16 valve DOHC rice burner can run a higher CR because combustion chamber volume and bore diameter (smaller is better) are also variables in the burn rate. Detonation usually manifests itself as severe stumbling or stuttering under heavy load acceleration.
If detonation occurs, try retarding the ignition in small increments until it goes away. Obviously you wouldn't want to retard much more than 6 to 8 degrees from max factory specifications. If detonation still occurs, try a slightly richer mixture (maybe raise the carb float level 1/16" and/or go up one size on the main jets, and/or go up one step richer on the Power Valve, and/or improve the accelerator pump shot). If you still have the problem you'll probably need to run gasoline additives (octane boosters), or for non-smog cars, mix CAM II (or other racing fuels) with pump gas. Some filling stations in larger cities have 100 octane unleaded gasoline.
Pinging is not good for an engine and should be corrected. Detonation can be deadly - it can destroy an engine - therefore it MUST be corrected. To set ignition timing correctly using today's fuels (assuming everything else is OK), warm the engine up completely, then slowly rotate the distributor until you get the highest vacuum reading (or highest RPM; both will occur at the same position), then lock down the clamp. Use your timing light only to make sure the advance unit is working properly. If you get detonation, back off about 2 degrees on the crank (about a thin pencil line width at the distributor base) and try again.