There are many ways to approach this problem. Here is one using an absorbing Discrete Time Markov Chain (DTMC) to handle all the conditioning via the fundamental matrix. If we have a fair coin, assume coin flips are independent and $p=Pr(Heads) = 0.5$. Let $N$ be the number of coin flips to reach the desired pattern.
Let $\{X_n,n=1,2,3,\ldots\}$ be a DTMC with one-step transition probability matrix $\mathbf{P}$ where $P_{ij}$ is the probability of transitioning to state $j$ from state $i$ (in one step).
The states are $X_n \in \{0, T, TH, THH\}$. The transition diagram is below.

The transition matrix is then
$$\mathbf{P}=
\left[ {\begin{array}{c c c c}
p & 1-p & 0 & 0 \\
0 & 1-p & p & 0 \\
0 & 1-p & 0 & p \\
0 & 0 & 0 & 1
\end{array} } \right].$$
In canonical form, this can be organized into block matrices denoted by
$$ \mathbf{P} = \left[ {\begin{array}{c c c c c c}
\mathbf{Q} & \mathbf{R} \\
\mathbf{0} & \mathbf{I} \\
\end{array} }\right],$$
where $\mathbf{Q}$ is a 3x3 square matrix, $\mathbf{R}$ is a 3×1 column vector, $\mathbf{0}$ is a 1x3 row vector, and $\mathbf{I}=[1]$ is a trivial 1×1 identity matrix.
The fundamental matrix $$\mathbf{S}=\left(\mathbf{I}_{3\times 3}-\mathbf{Q}\right)^{-1}$$ has the interpretation that $S_{ij}$ is the expected number of times the process is in transient state $j$ given that it started in transient state $i$.
Summing across the $i$th row of $\mathbf{S}$ gives the total number of transitions (flips) until absorption (achieving desired pattern) given you started in state $i$. Since we're starting with 0 coin flips (the first state), the desired quantity is then
$$\text{E}[N] = \sum_{j=1}^{3} S_{1j}=8$$
or, written with the state notation,
$$\text{E}[N] = \sum_{j\in\{0, T, TH\}} S_{0j}=8$$
Example MATLAB code:
p = 0.5; % prob(Heads)
P = [p 1-p 0 0;
0 1-p p 0;
0 1-p 0 p;
0 0 0 1];
Q = P(1:3,1:3);
S = inv(eye(size(Q))-Q);
avgN = sum(S(1,:))
avgN = 8