First things first, the setting in force when you do the redefinition of \@oddhead and \@oddfoot is $3 (the subscript denotes the catcode). At the time of the definition TeX reads the characters \the\catcode`$, $a + b = c$\hfill and turns them into tokens:
\the \catcode `12$3,1210$3a1110+1210b1110=1210c11$3\hfill
(A very useful tool to get this list of tokens is expl3's \tl_analysis_show:N .)
This tokenisation occurs with the catcode setting in force at the time the definition was made, and TeX won't change this even when catcodes change. Quoting The TeXBook (Chapter 8, The Characters You Type; emphasis mine):
[...] it is best not to play with the category codes very often, because you must remember that characters never change their categories once they have become tokens.
or, with an example, from Appendix D:
[...] TeX stamps the category on each character when that character is first read from a file. Thus, if \verbatim were defined by a construction of the form \long\def\verbatim#1{⟨something⟩}, argument #1 would already be converted to a list of tokens when ⟨something⟩ starts; \catcode changes would not affect the argument.
This is what is usually called "frozen catcodes" and, as Skillmon said in the comment, the only way to change it is with ε-TeX's \scantokens.
Now to your document, with \@oddhead and \@oddfoot already tokenised with $3, when the document begins the catcode of $ is still 3, as you see in the first equation. Then you change $ to catcode 12 and write another equation, which is not in math-mode anymore because $ is not catcode 3. And now the document ends.
TeX knows that you wrote something, but it still didn't try breaking the paragraphs into pages: everything you wrote until now is in a \vbox waiting to be shipped out. When LaTeX sees the \end{document} it starts preparing a final (an only in this case) page with what you wrote. Part of this preparation is the inclusion of headers and footers, at which time it uses \@oddhead and \@oddfoot. At this time the catcode of $ is queried by your definition, and it is 12, simply because you changed it.
There is no special catcode setting for page headers (not usually, at least), but it doesn't try to enforce any specific setting, so the last one active ($12) will be used. However the equations will still be in math-mode because the tokenized \@oddhead and \@oddfoot have $3. The conclusion is: the catcode of $ isn't changed by LaTeX's output routine; you changed it!
You can experiment by changing the catcode back:
\the\catcode`$, $a + b = c$\par
\catcode`$=12
\the\catcode`$, $a + b = c$
\catcode`$=3
or making the change in a group:
\the\catcode`$, $a + b = c$\par
{\catcode`$=12
\the\catcode`$, $a + b = c$\par}
and you'll see the settings are back to normal.
As an exercise, try playing with \scantokens (with \catcode`$=12 before the \end{document}):
\makeatletter
\def\@oddfoot{\the\catcode`$, \scantokens{$a + b = c$\hfill}}
\def\@oddhead{\scantokens{\the\catcode`$, $a + b = c$\hfill}}
\makeatother
(try to guess the output before running TeX)
$still works as a math shift, because the catcode of$at the time you defined\@oddfootand\@oddheadwas 3, the tokenization of it was done the moment it was defined and TeX doesn't change category codes of once tokenized text (unless you use\scantokens). – Skillmon Jul 06 '19 at 12:29