Disclosure: I wrote the samc R package used in this answer
This answer is more of a supplement to Stephan Kolassa's answer
In it, he showed how to construct a transition matrix representing the problem:
Image credit: Stephan Kolassa's answer
Now, as indicated in comments/another answer, this matrix can be simplified a variety of different ways, but I'm going to keep it as-is because there are other things about the experiment you can learn from it that you can't from the others.
Let's call this transition matrix $P$, which is how I define it in the samc package: samc overview
This can be broken down as:
$$
P =
\begin{bmatrix}
Q & R \\
0 & I
\end{bmatrix}
$$
Using this, there a variety of things you can calculate about the model. For example:
$$z=(I-Q)^{-1}{\cdot}1=F{\cdot}1$$
Will tell you the expected time to absorption given a starting transient state. In this example, that means that given your last 3 flips, how many more flips do you expect it to take before $HTH$ occurs. Some code:
library(samc)
p <- 0.05
q <- 1 - p
p_mat <- matrix(c(0, 0, 0, 0, 0, 0, q, p,
q, p, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, q, p,
q, p, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, q, p, 0, 0,
0, 0, q, p, 0, 0, 0, 0,
0, 0, 0, 0, q, p, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1),
8, byrow = TRUE)
rownames(p_mat) <- c("HHT", "HHH", "THT", "THH", "TTT", "TTH", "HTT", "HTH")
colnames(p_mat) <- c("HHT", "HHH", "THT", "THH", "TTT", "TTH", "HTT", "HTH")
# A samc object is the core of the package
samc_obj <- samc(p_mat)
# Given the last 3 flips, how many more flips until we hit HTH (absorption)?
survival(samc_obj)
[1] 420.0000 421.0526 420.0000 421.0526 441.0526 421.0526 441.0526
So, if we start with $HHT$, we expect it would take 420 flips on average to end up with $HTH$. $THT$ is the same, and they represent the best case scenario where we start only one flip away from $HTH$. Conversely, $TTT$ and $HTT$ are a worst case scenario where we start off needing 3 perfect flips; the result for these is 441.0526, the same as other answers.
As Neil Slater pointed out in a comment, the transition matrix can be reduced to 5 elements if this all you want. But there are other metrics to explore. For example, we can calculate the number of times we expect a sequence to occur before we hit $HTH$:
$$F = (I-Q)^{-1}$$
Here's some code (I include some code to show the relationship to the previous metric as well):
# Given a starting point (in this case, a sequence of 3 flips), how many times
# would we expect the different combinations of 3 flips to occur before absorption?
visitation(samc_obj, origin = "HHT")
[1] 1.95 0.05 18.05 0.95 361.00 19.00 19.00
sum(visitation(samc_obj, origin = "HHT")) # Compare to survival() result
[1] 420
# Instead of a start point, we can look at an end point and how often we expect
# it to occur for each of the possible starting points
visitation(samc_obj, dest = "THT")
[1] 18.05 18.05 19.05 18.05 19.00 19.00 19.00
# These results are just rows/cols of a larger matrix. We can get the entire matrix
# of the start/end possibilities but first we have to disable some safety measures
# in place because this package is designed to work with extremely large P matrices
# (millions of rows/cols) where these types of results will consume too much RAM and
# crash R
visitation(samc_obj)
Error: This version of the visitation() method produces a large dense matrix.
See the documentation for details.
samc_obj$override <- TRUE
visitation(samc_obj)
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 1.95 0.05000000 18.05 0.95 361 19 19
[2,] 1.95 1.10263158 18.05 0.95 361 19 19
[3,] 0.95 0.05000000 19.05 0.95 361 19 19
[4,] 1.95 0.10263158 18.05 1.95 361 19 19
[5,] 1.00 0.05263158 19.00 1.00 381 20 19
[6,] 1.00 0.05263158 19.00 1.00 361 20 19
[7,] 1.00 0.05263158 19.00 1.00 380 20 20
rowSums(visitation(samc_obj)) # equivalent to survival() above
[1] 420.0000 421.0526 420.0000 421.0526 441.0526 421.0526 441.0526
Another one:
$$D=(F-I)diag(F)^{-1}$$
would calculate the probability of a sequence of flips occurring before you hit $HTH$. And there's a "short-term" version of this:
$$\tilde{D}_{jt}=(\sum_{n=0}^{t-1}\tilde{Q}^n)\tilde{q}_j$$
which calculates the same thing, but within a given number of time steps (or coin flips in this context). So let's say you're interested in the probability of flipping $TTT$ with only 3 flips:
dispersal(samc_obj, dest = "TTT", time = 3)
[1] 0.902500 0.857375 0.902500 0.857375 NA 0.857375 0.950000
Depending on your last 3 flips, you basically have 3 options (4 if you count having already flipped $TTT$): $0.95$, $0.95^2=0.9025$, or $0.95^3= 0.857375$.
Obviously, some of these things can be easier or more intuitive to calculate using other methods, but once set up, absorbing markov chains give you a lot of flexibility in exploring a scenario.
A full list of the things you can calculate (at least using my package) are available in the function reference: samc functions. Which calculations are relevant depends on the context. When writing the functions, I used the book “Finite Markov Chains” by Kemeny and Snell as reference, which includes proofs. You can find the pdf of it online for free (legally, I believe) pretty easily.
Tying things back to OP's questions: as the other answers have shown, there are a variety of ways to mathematically model your experiment, including Markov chains. One thing Stephen Kolassa alluded to, and what I was hoping to show, is there is a LOT more you can learn about this experiment than you might have realized.
Note: the package was originally written for spatial applications, so a lot of the terminology in it is biased towards that. However, it is usable for pretty much any application of absorbing Markov chains