Suppose $X$ and $Y$ are (real-valued) non-negative random variables with the same distribution and finite second moment, then $\mathbb{E}[XY]$ is maximal if $X=Y$ a.s., since $\mathbb{E}[XY]\leq \sqrt{\mathbb{E}[X^2]\mathbb{E}[Y^2]} = \mathbb{E}[X^2]$ by Cauchy—Schwarz.
Now suppose I have some other non-negative random variable $Z$ (not necessarily with finite moments) and I have $\mathbb{E}[X^2Z]<\infty$ (but not necessarily $\mathbb{E}[Y^2Z]<\infty$). Do I then also have that $\mathbb{E}[XYZ] \leq \mathbb{E}[X^2 Z]$? If $Z$ is independent of $X$ and $Y$, this is easy, but what if we allow for dependence?
First, this will be true if (sufficient condition, not necessary) $\mathbb{E}[X^2 Z \mid Z]=\mathbb{E}[Y^2 Z \mid Z]$: $$\begin{align} \mathbb{E}[XYZ] &= \mathbb{E}[\mathbb{E}[XYZ\mid Z]] = \mathbb{E}[Z \mathbb{E}[XY \mid Z]] \\ &\leq \mathbb{E}[Z \sqrt{\mathbb{E}[X^2 \mid Z]\mathbb{E}[Y^2 \mid Z]}] \stackrel{(\star)}{=} \mathbb{E}[Z \mathbb{E}[X^2 \mid Z]] = \mathbb{E}[\mathbb{E}[X^2 Z \mid Z]] \\ &= \mathbb{E}[ X^2Z ] \end{align}$$
However, it is false in general. Consider $X,Y$ two independent r.v.'s, uniform on $[0,1]$; and $Z = \mathbf{1}_{\{Y>1/2\}}$. Then $$ \mathbb{E}[XYZ] = \mathbb{E}[X]\cdot\mathbb{E}[Y\mathbf{1}_{\{Y>1/2\}}] = \frac{1}{2}\cdot\frac{3}{8} = \frac{3}{16}\,; $$ however, $$ \mathbb{E}[X^2 Z] = \mathbb{E}[X^2]\cdot\mathbb{E}[\mathbf{1}_{\{Y>1/2\}}] = \frac{1}{3}\cdot\frac{1}{2} = \frac{1}{6} < \frac{3}{16}. $$