in some cases, yes. octane reduces the fuel's ignition potential. it can result in more hydrocarbons in the exhaust stream if the increased octane is too high for current engine requirements.
odd tht you would get a knock sensor code if the engine knocks. i've only seen the code happen when the knock sensor is faulty.