On any one flip, the probability that all three coins come up the same is $\frac{2}{8}=\frac14$ and the probability that they don't is $\frac34$. Hence, the probability that the three coins come up the same for the first time at exactly the $n$-th flip is ${\left(\frac34\right)}^{n-1}\frac14$.
The expectation is therefore given by
$$\sum_{n\geq 1}n{\left(\frac34\right)}^{n-1}\frac14=\frac14\cdot\sum_{n\geq 1}n{\left(\frac34\right)}^{n-1}.$$
Now, consider $f(x)=\sum_{n\geq0}x^n=\frac{1}{1-x}$, $|x|<1$. We have that
$$f'(x)=\sum_{n\geq1}nx^{n-1}=\frac{1}{{(1-x)}^2}.$$
It follows that the expectation equals
$$\frac14\cdot f'\left(\frac34\right)=\frac14\cdot\frac{1}{{\left(\frac14\right)}^2}=\frac14\cdot16=4$$
This was checking the whole thing via definitions. But you could have skipped it all noting that the chance of 'success' at each step is $1/4$, so the expected value, naturally, would be $4$.
We only ever need to keep track of the difference between the number of heads, and the number of tails. Moreover, the time it takes to increase this difference by $2$ is twice the time it takes to increase this difference by $1$.
So let's call $x$ the time it takes to go from a difference of $k$ to a difference of $k+1$: for example, the time it takes from the start until you have flipped heads once more than tails.
After the very first coinflip, we're either done (with probability $p$), or we have made progress in the wrong direction and have a difference of $2$ to make up for (with probablity $1-p$). So we have $$x = 1 + (1-p) \cdot 2x$$ or $x = \frac1{2p-1}$.
The answer you want is $2x = \frac2{2p-1}$.
Best Answer
Actually, the expected number of flips is $\infty$. Let $n$ denote (the number of tails $-$ the number of heads). Let $X_{n+1}$ denote the expected number of flips when you have $n$ more tails than heads. Suppose the process also ends when $n+1=w>0$, then \begin{align} X_{0}&=0&\\ X_{1}&=1+\frac12X_{0}+\frac12X_2&\\ X_{n}&=1+\frac12X_{n-1}+\frac12X_{n+1}&\\ \dots&=\dots\\ X_{w}&=0& \end{align} The solution of this inhomogeneous system of equations is $$X_n=n(w-n)$$ The expected number of flips is $$X_1=w-1\to\infty\:(w\to\infty)$$ if the flipping can continue indefinitely. The process ends with probability $1$ (eventually we will get more heads than tails), but the expected number of flips is infinite.