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 := \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 \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 = \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). \]