This is not true. Consider for instance $T\in B(\ell^2(\mathbb N))$ given by
$$
Tx=(x_1/2, 2x_2/3, 3x_3/4,\ldots).
$$
As $Te_n=\tfrac{n}{n+1}\,e_n$, we have that $\|T\|=1$. But for any nonzero $x$ with $\|x\|=1$ we have
$$
|\langle Tx,x\rangle|=\sum_n\tfrac{n}{n+1}\,|x_n|^2<\sum_n|x_n|^2=1.
$$
So no such maximum exists.
When $T$ is compact, though, the answer is affirmative. For a selfadjoint compact $T$, we have via the Spectral Theorem that
$$
T=\sum_n\lambda_nP_n,
$$
where $\lambda_n\in\mathbb R$ for all $n$, and $\lambda_n\searrow0$. In this case $\|T\|=\max_n|\lambda_n|$. If we take $|\lambda_j|=\|T\|$, then put $x$ with $P_jx=x$ and $\|x\|=1$, and
$$
|\langle Tx,x\rangle|=|\lambda_j|=\|T\|.
$$