It's the Exercise 3.3.35 of Karatzas and Shereve: Brownian Motion and Stochastic Calculus on page 168.
Let $W=\{W_t,\mathscr{F}_t; 0\leq t<\infty\}$ be a standard, one-dimensional Brownian motion, and let $T$ be a stopping time of $\{\mathscr{F}_t\}$ with $E[\sqrt T]<\infty$. Prove that $$E[W_T]=0, E[W_T^2]=E[T].$$
For each $t>0$, we have $$E[W_{T\wedge t}]=0, E[W_{T\wedge t}^2]=E[T\wedge t].$$ It suffices to show that $W_{T\wedge t}$ converges to $W_T$ as $t\to\infty$ in $L^2$ and thus in $L^1$. If $E[T]<\infty$, this post gives a proof. But here we only have $E[\sqrt T]<\infty$. By the Burkholder-Davis-Gundy inequality, $$E[\sup_{0\leq s\leq T}|W_s|]\leq CE[\langle W\rangle_T^{1/2}]=CE[\sqrt T]<\infty,$$ hence $W_{T\wedge t}$ converges to $W_T$ as $t\to\infty$ in $L^1$ and now the first identity follows.
As for the $L^2$ convergence, I have no idea.
Any help would be appreciated.