I have known that if $A$ is a densely defined (unbounded) operator with domain $D(A)$ such that $\langle Ax,x\rangle=0$ for all $x\in D(A)$, then this does imply that $Ax=0$ for all $x\in D(A)$. This result may be found e.g. in Schmudgen's new book on unbounded self-adjoint operators.
However the following is a purported counter-example in these notes:
Consider the differential operator $T:x\mapsto \frac{dx}{dt}$ defined on $C_c^{\infty}(\mathbb{R})$ which is a dense subset of $L^2(\mathbb{R})$. Suppose then $x\in C_c^{\infty}(\mathbb{R})$, then
$$ \int_{\mathbb{R}}\frac{dx}{dt} x\,dt = x^2\bigg|_{-\infty}^{\infty} - \int_{\mathbb{R}} x\frac{dx}{dt}\,dt. $$
Hence $\langle Tx,x\rangle = 0$ for all $x\in C_c^{\infty}(\mathbb{R})$ but $Tx\neq 0$ for some $x$.
Any help please!
Cheers...