You seem to want something like this:
1 Section title A
Some text following.
1.1 Theorem. The statement of the theorem
Some text following.
1.2 Theorem. The statement of the theorem
Some text following.
1.1 Subsection title A
Some text following.
1.1.1 Theorem. The statement of the theorem
Some text following.
1.1.2 Theorem. The statement of the theorem
Some text following.
1.2 Subsection title B
1.2.1 Theorem. The statement of the theorem
2 Section title B
Some text following.
2.1 Theorem. The statement of the theorem
Some text following.
2.2 Theorem. The statement of the theorem
Here's the code.
\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[subsection]% theorem is reset at subsections
\counterwithin*{theorem}{section}% theorem is also reset at sections
\renewcommand{\thetheorem}{%
\ifnum\value{subsection}>0
% we're after \subsection
\thesubsection
\else
% no \subsection came along yet
\thesection
\fi
.\arabic{theorem}%
}
\begin{document}
\section{Section title A}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
Some text following.
\subsection{Subsection title A}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
\begin{theorem}
The statement of the theorem
\end{theorem}
\subsection{Subsection title B}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
\section{Section title B}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
Some text following.
\begin{theorem}
The statement of the theorem
\end{theorem}
\end{document}

Don't. Just use
\newtheorem{theorem}{Theorem}[section]
and your readers will be happier.