Headings are appropriate to use when your professor/assignment prompt requires it or allows you to decide whether to use them or not. Headings should not replace topic sentences. You should always include a topic sentence in your paragraphs, using transitional words and phrases to help introduce your idea.
It really depends on the kind of paper being written. A classic 5-paragraph argumentative essay should NOT have headings. But, something in the sciences or engineering might benefit dramatically from having headings.
For classes, make sure you know what the professor is looking for because it depends on the situation whether you should use them or not. But, in general the humanities (history, English etc.) do not need headings while the hard sciences (biology, engineering, chemistry) can use them.