\documentclass{article} % Herbert Voss
\usepackage{xcolor}
\let\mySection\section
\renewcommand\section[1]{%
  \mySection[#1]{\protect\textcolor{green}{#1}}%
}
\let\myTOC\tableofcontents
\renewcommand{\tableofcontents}{%
  \let\section\mySection
  \myTOC
  \renewcommand\section[1]{%
    \mySection[##1]{\protect\textcolor{green}{##1}}%
  }}

\begin{document}
\tableofcontents
\section{foo}
bar 
\subsection{baz}
bar 

\end{document}
