The spermaceti organ in the heads of sperm whales produces a waxy substance ('whale oil'). It's also produced in smaller quantities in other whale species.
There are three main theories regarding possible function(s).
1) As an adjustable buoyancy device
2) As a buffer in collisions
3) As an echo resonator
No theory has been agreed upon.
Note: More detail and references required