The Schwartz space, $S(\mathbb R): = \{f\in C^{\infty}(\mathbb R): \sup_{x\in \mathbb R} |x^{\alpha} D^{\beta}f(x)|< \infty , \forall \alpha, \beta \in \mathbb N \cup \{0\} \}$ and $S'(\mathbb R) = \text {The Space of continuous linear functionals on} \ S(\mathbb R)$ (tempered distributions).
The Sobolev Space,
$$H_{1}:= \left \{f\in S'(\mathbb R): [\int_{\mathbb R} |\hat {f}(\xi)|^{2} (1+|\xi|^{2}) d\xi]^{\frac {1}{2}} < \infty \right \}$$
It is well know that, $S(\mathbb R)$ is a subspace of $H_{1}$.
My question is: Let $f\in S(\mathbb R)$ such that $|f|\not \in S(\mathbb R)$.
Is it true that $|f| \in H_{1}$ or we can produce counter example ?
As @GiuseppeNegro pointed out, this is a result of Stampacchia. I will give you some references:
I - The original paper of Stampacchia.
II - Brezis book.
III - Ziemer's book.
The theorem in II is less general, but it fits well in what you need and its proof is more simple. I will not post the pages, so you can have the pleasure of searching for it in those interesting reads.