This can be achieved for example with a small patch to the \@sect command, which is responsible for the typesetting of the section title.
The specific section type must be filtered and then \xrfill with a raising of about half of the letter height (0.5ex), a rule width and a rule colour (see the package documentation) (For this question I used some code from my answer to this question here: Underline subsection heading)
\documentclass{article}
\usepackage{xhfill}
\newlength{\subsectionrulewidth}
\newlength{\subsectionruleraise}
\setlength{\subsectionrulewidth}{2pt}
\setlength{\subsectionruleraise}{0.5ex}
\newcommand{\subsectionrulecolour}{blue}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@sect}{%
#8%
}{%
\ifstrequal{#1}{subsection}{%
#8 \xrfill[\subsectionruleraise]{\subsectionrulewidth}[\subsectionrulecolour]%
}{%
#8 %
}%
}{\typeout{successful patching}}{\typeout{Nope}}
\makeatother
\begin{document}
\tableofcontents
\section{First}
\subsection{Some Title}
\subsection{Some other title}
\subsubsection{No line}
\end{document}
