If $X$ is a r.v. on $(\Omega,\mathcal E, P)$ I have
$E(X)=\int_\Omega X \, dP$
$\mathrm{Var}(X)=\int_\Omega (X-E(X))^2 \, dP=\int_\Omega X^2 \, dP - 2E(X) \int_\Omega X \, dP + E(X)^2 $
so
$X \in L^1(P) \Rightarrow E(X) < +\infty$
and (because $P$ finite $\Rightarrow L^2(P) \subseteq L^1(P)$)
$X \in L^2(P) \Rightarrow\mathrm{Var}(X) < +\infty$
Now I would like to find similar sufficient conditions on the pmf and the pdf. For the continuous case, if $X$ admits a density $f$
$E(X)=\int_\mathbb R x f(x) dx$
$\mathrm{Var}(X)=\int_\mathbb R (x - E(X))^2 f(x) dx=\int_\mathbb R x^2 f(x) dx - 2E(X)\int_\mathbb R x f(x) dx + E(X)^2 $
so it's enough for the existence of mean and variance that
$\int_\mathbb R |x|f(x) dx < +\infty$ and $\int_\mathbb R (x-E(X))^2f(x) dx < +\infty$
Is there any condition on $f$ such that the previous integral converge?
(I already find that $\int_\mathbb R x^2 f(x) dx < +\infty \Rightarrow \int_\mathbb R |x|f(x) dx < +\infty$ then $\mathrm{Var}(X)<+\infty \Rightarrow E(X)<+\infty$).
You need $\int_{\mathbb R} x^2 \; f(x)\; dx < \infty$. You already said you need $X \in L^2(P)$, and $E(X^2) = \int_{\mathbb R} x^2\; f(x)\; dx$ for a random variable with a density.