The inner product space you might have in mind is $L^2(\Omega, \mathscr A, P)$, the space of all square integrable random variables $X \colon \Omega \to \mathbb R$. Square integrable means that we have
\[ \|X\|^2 := E(|X|^2) = \int_{\Omega} |X|^2\, dP < \infty \]
The inner product is given by
\[
\left<X,Y\right> := \int_\Omega XY\, dP.
\]
So it isn't a sum, but an integral and the vectors are the elements of the vector space $L^2(\Omega)$, that is, random variables.
Cauchy-Schwarz reads
\[
\int_\Omega XY\, dP = \left<X,Y\right> \le \|X\|^2 \|Y\|^2 = \int_\Omega X^2\, dP \cdot \int_\Omega Y^2\, dP
\]
and applying this to $X-E(X)$ and $Y - E(Y)$ gives the desired inequality.
In cases where $P$ is discrete, that is there is a countable subset $\Omega'$ of $\Omega$ with $P(\Omega') = 1$, the integrals are sums, in this case we have
\[
\left<X,Y\right> = \int_\Omega XY\, dP = \sum_{\omega \in \Omega'} X(\omega)Y(\omega)
\]
and
\[ \left\|X\right\|^2 = \sum_{\omega \in \Omega'} X(\omega)^2. \]
$\def\cov{\operatorname{cov}}$
Addendum after comment: As you write, for discrete random variables we have
\[
\cov(X,Y) = \sum_{\omega\in \Omega} \bigl( X(\omega) - E(X)\bigr)\bigl(Y(\omega) - E(Y)\bigr)
\]
If we want to write this as a sum over the values of $X$ and $Y$, just note that the joint probability mass (or as you write density) function $p_{X,Y}$ is given by
\[
p_{X,Y}(x,y) = P({\omega \mid X(\omega) = x, Y(\omega) = y})
\]
Grouping these terms in the above sum, we obtain
\[
\cov(X,Y) = \sum_{x\in X[\Omega]}\sum_{y\in Y[\Omega]} \bigl(x- E(X)\bigr)\bigl(y-E(Y)\bigr)p_{X,Y}(x,y).
\]
Best Answer
There is a generalization of Cauchy Schwarz inequality from Tripathi [1] that says that: \begin{equation} \mathrm{Var}(Y) \ge \mathrm{Cov}(Y,X)\mathrm{Var}(X)^{-1}\mathrm{Cov}(X,Y) \end{equation} in the sense that the diference is semidefinite positive. He actually says that a student asked about it and couldn't find any other reference (1998!).
[1]: G. Tripathi, ”A matrix extension of the Cauchy-Schwarz inequality”, Economics Letters, vol. 63, nr 1, s. 1–3, apr. 1999, doi: 10.1016/S0165-1765(99)00014-2.