Don't use \stepcounter
in the argument of \subsection
. Even if preceding it with \protect
in order to avoid the error, this will have adverse effect when \tableofcontents
is used. The following example shows it clearly (I used \section
, but it's exactly the same with \subsection
, provided it goes in the table of contents).
\documentclass{article}
\newcounter{lecCounter}
\newcommand{\lecID}{\protect\stepcounter{lecCounter}\thelecCounter}
\begin{document}
\tableofcontents
\section{Lecture \lecID}
Text.
\end{document}

What you should do is to define a new command:
\newcommand{\lecture}{%
\stepcounter{lecCounter}%
\subsection{Lecture \thelecCounter}%
}
Fine tuning is possible, depending on your needs; for instance if you need to refer to the lecture number rather than to the subsection number. Another possibility would be adding an optional argument for a specific lecture title. Better encoding all this into a command, rather than chasing into the document if a change is needed.
A sample document might be
\documentclass{article}
\newcounter{lecCounter}
\newcommand{\lecture}{%
\stepcounter{lecCounter}%
\subsection{Lecture \thelecCounter}%
}
\begin{document}
\tableofcontents
\section{Group of lectures}
\lecture
Text.
\lecture
Text.
\end{document}
{}
"button" in the ribbon above the edit window -- the site software will pretty-print them automatically. – Mico Dec 22 '14 at 6:28