In brief
The octane number describes the anti-detonation property of gasoline. The choice begins with the requirements of the particular engine.
Useful to know
The octane number is related to the resistance of gasoline against detonation combustion. The EIA uses it to explain the differences between the gasoline classes, and stresses that the manufacturer of the car sets the appropriate class for the model. [1]
The larger number should not automatically translate as "more energy per liter" or the promise of an equal increase in power for each engine. It describes a specific property of the fuel, and the result also depends on the engine and its management.
Practically start from the manual, not from the advertising name of the column. Various trade names may indicate fuel classes. If you are reading an American source, do not mechanically compare the numbers on its columns with European markings without checking the system used.
This material explains the principle. It does not set fuel for a specific car and does not replace its requirements with a general "always the highest number" rule.
Sources
For further detail and to check the information: