You just need to copy the definition of subsection from your class (I'm assuming article here) and make the changes you want.
\newcounter {subsection}[section]
It has a counter, reset every section.
\renewcommand\thesubsection {\thesection.\@arabic\c@subsection}
The section counter prefixes this counter when displayed
\newcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}
The fonts and spacing used for the heading
\newcommand\appendix{\par
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\gdef\thesection{\@Alph\c@section}}
It's reset in the appendix
\newcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}
Uses a dotted line format in the table of contents