Is there a function which is square integrable and doesn't tend to zero at infinity but it belongs in the domain of the momentum operator? Is there a function which is square integrable and doesn't tend to zero at infinity but it belongs in the domain of the momentum operator? 
There are some counterexample for functions that are square-integrable but doesn't tend to zero at infinity. However these counterexamples are not member of the domain of the momentum operator.
 A: The short answer is: No, there is no such function.
Indeed, it is false that $f\in L^2(\mathbb R, dx)$ vanishes at infinity as is well known (there are also some answers  in PSE concerning this issue) but it is also true that, if $D(P)$ is the domain of the momentum operator $P$ over the real line,
$\qquad\qquad\qquad\qquad\qquad\qquad$$f \in D(P)\quad$ implies that $\quad f(x) \to 0\quad$ as $\quad x\to \pm\infty$.
Let us prove this fact.
First of all, notice that one of the equivalent ways to define $D(P)$ in order to have a properly selfadjoint  momentum operator in $L^2(\mathbb R , dx)$ is
$$D(P) := \left\{\: \left.f \in L^2(\mathbb R, dx)\:\right|\: \exists \: f' \mbox{in weak sense and } f' \in  L^2(\mathbb R, dx)\right\}\:,$$
and then, where $f'$ is the  weak derivative of $f$, the momentum operator is defined as the selfadjoint operator
$$Pf = -i\hbar f'\:.$$
So, let  us assume $f\in D(P)$. Since $[s,s']$ has finite Lebesgue measure $f\in L^2([s,s'], dx)$ implies $f\in L^1([s,s'], dx)$, so $F(s) := \int_{s'}^s f'(x)dx$
exists. It is obvious that it is also a continuous function in view of the properties of the integral. From known theorems of real analysis we also known that
$$f(s')-f(s) = \int_s^{s'} f'(x)dx \quad \mbox{almost everywhere}\:.\tag{1}$$
In particular  we can fix $f$ to be continuous everywhere since, modifying  $f$ over a zero-measure set, $f(x)= f(s)+ F(x)$.
Now we can take advantage of Chaucy-Schwartz inequality in (1):
$$|f(s')-f(s)| \leq \int_s^{s'} |f'(x)| |1|dx \leq \sqrt{\int_s^{s'} |f'(x)|^2  dx}\sqrt{\int_{s}^{s'}|1|^2 dx} \leq ||f'||_{L^2} \sqrt{|s-s'|}\:.$$
Notice that $||f'||_{L^2} <+\infty$ by hypothesis. The estimate
$$|f(s)-f(s')| \leq ||f'||_{L^2} \sqrt{|s-s'|},$$
which is valid everywhere with our choice of $f$,
implies that $f$ is uniformly continuous over the whole $\mathbb R$.
To conclude I prove that
PROPOSITION. If $f: \mathbb R \to \mathbb C$ is uniformly continuous and $f\in L^p(\mathbb R, dx)$, for some $p>0$ (in particular $p=2$) then $f(x) \to 0$ both for $x\to +\infty$ and $x\to -\infty$.
PROOF. Suppose that it is false that $f(x) \to 0$ for $x\to +\infty$ (the other case is analogous).  We can assume that $f$ is real valued, since if the thesis is false either $Ref$ or $Im f$ (which belong to $L^p$ and are uniformly continuous) do not tend to $0$ as $x \to \pm \infty$.  Hence, there is $M>0$ and a sequence $x_n \to +\infty$ as $n\to +\infty$ such that $|f(x_n)| >M$. As a consequence, I can extract a subsequence  satisfying
$f(x_{n_k})>M$ for every $k$ or $f(x_{n_k})< -M$ for every $k$. I suppose valid the former since the latter can be treated analogously. Since $x_{n_k} \to +\infty$ as $k\to +\infty$, I can
extract another subsequnce $x_{n_{k_h}} \to +\infty$ as $h\to +\infty$  such that
$x_{n_{k_{h+1}}}- x_{n_{k_h}}>1$ and, as said $f(x_{n_{k_h}})>M$.
For the sake of simplicity I henceforth  define $s_h := x_{n_{k_h}}$.
Now observe that, by uniform continuity, if $\epsilon = M/2$, there is $\delta>0$ such that $$|f(s)-f(s_h)|< M/2 \quad \mbox{if $|s-s_h|<\delta$  for every $h\in \mathbb N$.}$$
Hence
$$-M/2 <f(s)- f(s_h)< M/2$$
so that, in particular
$$M/2 < f(s_h) -M/2 < f(s)\quad \mbox{if $|s-s_h|<\delta$.} $$
In summary, taking $\delta < 1/2$ if necessary, we have an infinite class of pairwise disjoint intervals $I_h = [s_h-\delta,s_h+\delta]$ with identical length $2\delta>0$ where $f(s) > M/2 >0$. Therefore
$$\int_{\mathbb R} |f(x)|^p dx \geq \sum_{h\in \mathbb N} \int_{I_h} |f(x)|^p dx \geq \sum_{h\in \mathbb N} 2\delta M^p/2^p= +\infty\:.$$
This is impossible since $f\in L^p(\mathbb R, dx)$ and thus the said sequences do not exist and $f(x) \to 0$ for $x\to \pm \infty$. QED
