Subheadings are always used in reports in business and in scientific case-studies, and not usually used in essays in subjects like English or History. Essays in more formal subjects like Social Sciences sometimes use subheadings and sometimes don't. In general, the more formal you want your assignment to look, the more you should use subheadings.
If you're writing a long essay (3,000 words or more) then
you should consider using subheadings, if it's permitted for your subject area. Subheadings are useful in a long piece of work because breaking a
long essay up into smaller bits makes it clearer. Subheadings can also
help to make the structure of a long argument clear.