This is done by a process called cracking.
Cracking is the process by which the crude oil is heated up in the oil refineries to separate the oil into separate molecules/hydrocarbons.
By heating the crude oil, it is boiled/evaporated - this is the process of converting a liquid to a gas.
The column in which they are heated in hotter at the bottom and cooler at the top. Because the separate molecules/hydrocarbons have different boiling points, they condense (turn from vapour to liquid) at different temperatures, this is the process of separating into their different fractions.