I'm refering to this question, which was already answered with a hint.
I repeat it here:
Let $(B_t)_{t\geq 0}$ be a standard Brownian motion and for $a<0<b$ define the stopping time $\tau=\inf\{t\geq 0:B_t\in \{a,b\}\}$. Now I want to calculate $E(\tau^2)$.
But I have trouble using the first hint stated in the link. That is using the fact that $B_t^3-3tB_t$ is a martingale to deduce $E(\tau B_\tau^2)$ and I hope that someone could help at that particular point.
There are a number of things that need to be calculated before arriving at the final answer.
First we keep in mind that $P(B_{\tau}=a)=\frac{b}{b-a}$ and $P(B_{\tau}=b)=\frac{a}{a-b}$.
Consider the martingale $B_t^2-t$.
$$ \begin{align*} E(B_{\tau}^2-\tau)&=0 \\ E(B_{\tau}^2\mid B_{\tau}=a)P(B_{\tau}=a)+E(B_{\tau}^2\mid B_{\tau}=b)P(B_{\tau}=b)-E(\tau)&=0 \\ a^2\frac{b}{b-a}+b^2\frac{a}{a-b}-E(\tau)&=0 \\ E(\tau)&=\frac{a^2b-b^2a}{b-a} \\ E(\tau)&=-ab. \end{align*} $$
Use the first hint in the link to get an equation involving $E(\tau\mid B_{\tau}=a)$ and $E(\tau\mid B_{\tau}=b)$.
$$ \begin{align*} E(B_{\tau}^3-3\tau B_{\tau})&=0 \\ E(B_{\tau}^3\mid B_{\tau}=a)P(B_{\tau}=a)+E(B_{\tau}^3\mid B_{\tau}=b)P(B_{\tau}=b) \\ -3E(\tau B_{\tau}\mid B_{\tau}=a)P(B_{\tau}=a)-3E(\tau B_{\tau}\mid B_{\tau}=b)P(B_{\tau}=b)&=0 \\ a^3\frac{b}{b-a}+b^3\frac{a}{a-b}-3aE(\tau\mid B_{\tau}=a)\frac{b}{b-a}-3bE(\tau\mid B_{\tau}=b)\frac{a}{a-b}&=0 \\ a^3b-b^3a-3abE(\tau\mid B_{\tau}=a)+3abE(\tau\mid B_{\tau}=b)&=0 \\ E(\tau\mid B_{\tau}=b)-E(\tau\mid B_{\tau}=a)&=\frac{b^2-a^2}{3}. \end{align*} $$
We have
$$ \begin{align*} E(\tau\mid B_{\tau}=a)P(B_{\tau}=a)+E(\tau\mid B_{\tau}=b)P(B_{\tau}=b)&=E(\tau) \\ E(\tau\mid B_{\tau}=a)\frac{b}{b-a}+E(\tau\mid B_{\tau}=b)\frac{a}{a-b}&=-ab \\ bE(\tau\mid B_{\tau}=a)-aE(\tau\mid B_{\tau}=b)&=-ab(b-a). \end{align*} $$
Combine this with the equation earlier to get a system of equations you need to solve.