Some supplements to Werner's great answer, in case you are using titlesec, for which Werner's patch does not work.
First, a quick aside of using \nolinenumbers and \linenumbers. Actually, in my own packages or classes, I usually have the following:
\newif\ifLNturnsON
\def\LocallyStopLineNumbers{\LNturnsONfalse%
\ifLineNumbers\LNturnsONtrue\fi\nolinenumbers}
\def\ResumeLineNumbers{\ifLNturnsON\linenumbers\fi}
\LocallyStopLineNumbers and \ResumeLineNumbers are better than just \nolinenumbers and \linenumbers in that they detect if the line numbering has already been turned on, so after disabling the line numbers \ResumeLineNumbers won't enable it if the user hasn't enabled the line numbering at the time of \LocallyStopLineNumbers.
With titlesec, you can add \LocallyStopLineNumbers to the beginning of the format, and [\LocallyStopLineNumbers] to the end. In the following example, I included a complete set of formats that mimic the default styles (the code is copied from documentation of titlesec, "8.2. Standard Classes"). You can of course modify your own style in the similar way.
\documentclass{article}
\usepackage{lineno}
\usepackage{lipsum}
\usepackage{titlesec}
\newif\ifLNturnsON
\def\LocallyStopLineNumbers{\LNturnsONfalse%
\ifLineNumbers\LNturnsONtrue\fi\nolinenumbers}
\def\ResumeLineNumbers{\ifLNturnsON\linenumbers\fi}
\makeatletter
\titleformat{\chapter}[display]
{\LocallyStopLineNumbers\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}[\ResumeLineNumbers]
\titleformat{\section}
{\LocallyStopLineNumbers\normalfont\Large\bfseries}{\thesection}{1em}{}[\ResumeLineNumbers]
\titleformat{\subsection}
{\LocallyStopLineNumbers\normalfont\large\bfseries}{\thesubsection}{1em}{}[\ResumeLineNumbers]
\titleformat{\subsubsection}
{\LocallyStopLineNumbers\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}[\ResumeLineNumbers]
\titleformat{\paragraph}[runin]
{\LocallyStopLineNumbers\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}[\ResumeLineNumbers]
\titleformat{\subparagraph}[runin]
{\LocallyStopLineNumbers\normalfont\normalsize\bfseries}{\thesubparagraph}{1em}{}[\ResumeLineNumbers]
\titlespacing{\chapter} {0pt}{50pt}{40pt}
\titlespacing{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing{\paragraph} {0pt}{3.25ex plus 1ex minus .2ex}{1em}
\titlespacing{\subparagraph} {\parindent}{3.25ex plus 1ex minus .2ex}{1em}
\makeatother
\linenumbers
\begin{document}
\section{A section} \lipsum[2]
\subsection{Another section} \lipsum[2]
\subsubsection{Final section} \lipsum[2]
\end{document}

titlesec, orhyperref, or...)? – Werner Nov 11 '13 at 06:02