Determine whether the following integral inequality holds Suppose that $\int_0^1 f dx = 0$. Is it true that
$$\left( \int_0^1 fg dx \right)^2 \leq \left( \int_0^1 g^2 dx - \left( \int_0^1 g dx \right)^2 \right) \left( \int_0^1 f^2 dx \right)$$
For context, this was stated as a true or false question on an old qualifying exam. I've tried noting that
$$ \int_0^1 fg dx  = \int_0^1 f (g-1) dx$$
Then, employing Cauchy-Schwarz gives
$$\left( \int_0^1 f g dx \right)^2 \leq \left( \int_0^1 g^2 dx - 2 \int_0^1 g dx +1 \right) \left( \int_0^1 f^2 dx \right)$$
From here, I thought I had it, since we have that $-2 \int_0^1 g dx + 1 \geq -\left( \int_0^1 g dx \right)^2$, but of course the inequality is going in the wrong direction. I tried to build some counterexamples, but everything I've tried has shown the inequality to be true. Any help is appreciated!
This is true. If $\int_0^1g(x)dx=0$, this is just Cauchy-Schwarz. Now note that neither side changes if you shift $g$ by a constant.
If probabilistic arguments are employed, we can simplify the arguments without writing integrals.

Suppose $X\sim U[0,1]$.  We rewrite the given inequality in terms of expected values:
$$E[f(X)g(X)]^2 \le var[g(X)]E[f(X)^2].$$
As @Jason points out, shifting $g$ by a constant doesn't affect the inequality (since $E[f(X)]=0$, so $E[f(X)(g(X)+k)]=E[f(X)g(X)+kf(X)]=E[f(X)g(X)]$), so the given inequality holds if and only if
$$E[f(X)(g(X)-k)]^2 \le var[g(X)-k]E[f(X)^2].$$
To apply the Cauchy-Schwartz inequality, we take $k=E[g(X)]$, so that $var[g(X)-k]=E[(g(X)-k)^2]$.  Then it's equivalent to
$$E[f(X)(g(X)-E[g(X)])]^2 \le E[(g(X)-E[g(X)])^2]E[f(X)^2].$$

This is the Cauchy-Schwartz inequality which holds for any random variables.