Fuel is used to power smelters, forges, glass furnaces, and kilns. Three types of fuel exist in Dwarf Fortress: charcoal, coke, and magma.
Charcoal and coke are, for all intents and purposes, identical - they can be used interchangeably to power the above workshops. However, harnessing the power of magma requires building magma smelters, magma forges, magma glass furnaces, and magma kilns along the edge of the magma flow using steel bars.
Charcoal is created from logs at a wood furnace. Coke is smelted from bituminous coal at a smelter.
In addition to their role as fuel, coke and/or charcoal are used as ingredients in the production of pig iron and steel, whether at a normal smelter or a magma smelter.