Let our random variable, the count of tosses until termination, be denoted as $N$.
If the termination is the first occurance of two consecutive tosses of the same result, then you must toss a pattern like $\sf\ldots THTHTHTT$ or $\sf\ldots HTHTHTHH$ . Ie: Always alternating until the very end. Obviously.
So, to stop on toss # $2k$, for any $k\in\{1,2,\ldots\}$, you must toss either: $k-1$ consecutive $\sf TH$ pairs then a $\sf TT$ pair, or $k-1$ consecutive $\sf HT$ pairs then a $\sf HH$ pair. So what is $\mathsf P(N=2k)$ ?
Likewise to stop on toss # $2k+1$, for any $k\in\{1,2,\ldots\}$, you must toss either: $k$ consecutive $\sf TH$ pairs then a single $\sf H$, or $k$ consecutive $\sf HT$ pairs then a single $\sf T$ . So what is $\mathsf P(N=2k+1)$ ?
Then you have a piecewise function for your probability depending on whether the count you seek is even or odd. $$\mathsf P(N{=}n) ~=~ \begin{cases} \color{green}{\underline{\qquad}} &:& n\in 2\Bbb N^+ \\[1ex] \color{green}{\underline{\qquad}} &:& n\in 2\Bbb N^+{+}1\end{cases}$$