How can I swap oil for diesel and kerosene?

Click the Oil refinery building and then "Resources". A window will open where you can use the sliders or manually adjust how many resources you want to swap; bellow you can see the rates and costs for swapping the resources.