The Spermaceti organ found in the heads of sperm whales produces an oily/waxy substance. There can be up to 2 tonnes of oil in each animal. It's also produced in smaller quantities in some other whale species.
Before whaling was made illegal (in most countries) there was a large market for the oil, which was used in lamps, candles, medicines and for specialist lubrication.
There are three main theories regarding its possible function(s).
To date, no theory has been agreed upon.
See: Wikipedia