There are two reasons why this can fail:
$|f|$ does not achieve its maximum; this occurs in the example given by Gastón Burrull.
The supremum of $|f|$ may not be the supremum of $f$. For example, even though $f(x)=-\exp(-x^2/2)$ is such that $|f|$ achieves its maximum (which is $1$ at $x=0$), there is no point where $f(x)=1$ because $f(x)\lt 0$ for all $x$.
So, first, your conclusion should be "there exists $x$ such that $|f(x)|=c$." The conclusion will follow in several situations; for example, it will follow if $\lim_{x\to\infty}|f(x)|\lt c \qquad \text{and}\qquad \lim_{x\to-\infty}|f(x)|\lt c.$ Indeed, assume that this is the case: let $R=\lim\limits_{x\to\infty}|f(x)|$ and $L=\lim\limits_{x\to-\infty}|f(x)|$. Then there exists $N\gt 0$ such that for all $x\gt N$ $\Bigl| |f(x)|-R\Bigr|\lt \frac{1}{2}(c-R)$, and there exists $M\gt 0$ such that for all $x\lt -M$, $\Bigl| |f(x)|-L\Bigr|\lt \frac{1}{2}(c-L)$. Then for all $x\notin [-M,N]$, we have $|f(x)|\lt c - \frac{1}{2}\min\{c-L, c-R\}$, so $|f(x)|$ does not get arbitrarily close to $c$ on $(-\infty,M)\cup (N,\infty)$. Thus, the supremum must be achieved inside the finite closed interval $[-M,N]$, and since $|f(x)|$ is continuous, the supremum is actually achieved, so there exists $a\in [-M,N]$ such that $|f(a)|=c$.
(The case where $\lim\limits_{x\to\infty}f(x) = \lim\limits_{x\to-\infty}f(x) = 0$ is a special case of the above when $f$ is not the constant function $0$).
In fact, a weaker condition is that the result will follow if there exists $N\gt 0$ such that $\sup_{|x|\gt N}|f(x)|\lt c$, which is really all we need above to reduce to a bounded interval where $f$ must take the value $c$. And also under the even weaker condition that there exist $N\gt 0$ such that $\sup\{|x|\leq N\} |f(x)| = c$.