You often get this problem if you put spaces/whitespace after the end of what should just be a code file.
So, for example, at the end of functions.php if you have:
// PHP code
?>
CRLF
CRLF
That will cause the warning above (CRLF is, of course, so you can see I mean carriage return!).
The best way to solve this is NOT to close the PHP in all code files – ie remove the last
?>
The reason this happens is that the carriage returns get treated as part of the HTML output and so get written to the response stream – ie starting to write the headers. However, functions.php (and lots of other files) get processed before some header work is done – hence the problem.
So, the answer is always from the last ?> from any “code only” file.