The minimum ratio is $27$, achieved by a piecewise quadratic polynomial in $x$.
This is sort of expected. When one throw the functional
$$\int_0^1 f'(x)^2 dx$$
to Euler-Lagrange equation and subject it to the constraints
$$\int_0^1 f(x) dx = \text{constant}\quad\text{ and }\quad
\int_{1/3}^{2/3} f(x) dx = 0$$
One find $f''(x)$ has to be a piecewise constant.
It takes one value over $[0,\frac13) \cup (\frac23,1]$ and another value over $(\frac13,\frac23)$. What I has done is use a CAS to pin down the correct piecewise quadratic polynomial and then verify it give us the minimum.
Let $X = \mathcal{C}^1[0,1]$ and $P,Q,C : X \to \mathbb{R}$ be the functionals over $X$ defined by
$$P(f) = \int_0^1 f'(x)^2 dx,\quad
Q(f) = \int_0^1 f(x) dx,\quad\text{ and }\quad C(f) = \int_{1/3}^{2/3} f(x) dx$$
The question can be rephrased as
What is the minimum of the ratio $\frac{P(f)}{Q(f)^2}$ for $f \in X$ subject to the constraint $C(f) = 0$.
Since the ratio and constraint are both invariant under scaling of $f$ by constant, we
can restrict our attention to those $f$ which satisfies $C(f) = 0$ and $Q(f)$ equal to a specific constant.
For any $K \in \mathbb{R}$, let $Y_K = \big\{\; f \in X : C(f) = 0, Q(f) = K\; \big\}$.
Consider following function over $[0,1]$
$$g(x) = \begin{cases}
4 - 27x^2, & x \in [0,\frac13]\\
54(x^2-x) + 13, & x \in [\frac13,\frac23]\\
4 - 27(1-x)^2, & x \in [\frac23,1]
\end{cases}$$
We have
$$
g'(x) = \begin{cases}
-54x, & x \in [0,\frac13]\\
54(2x-1),& x \in [\frac13,\frac23]\\
54(1-x),& x \in [\frac23,1]
\end{cases},\quad
g''(x) = \begin{cases}
-54, & x \in [0,\frac13) \cup (\frac23,1]\\
108, & x \in (\frac13,\frac23)
\end{cases}
$$
It is not hard to see $g \in X$. With a little bit of effort, one can verify
$P(g) = 108$, $Q(g) = 2$ and $C(g) = 0$. This means $g \in Y_2$.
For other $f \in Y_2$, it is easy to see $\eta = f - g \in Y_0$. We can decompose $P(f)$ as follows
$$P(f) = \int_0^1 (g'(x)+\eta'(x))^2 dx = \int_0^1 (g'(x)^2 + \eta'(x)^2 + 2g'(x)\eta'(x)) dx$$
Let us look at the cross term. Integrate by part and using the fact $g'(0) = g'(1) = 0$, we find
$$\begin{align}\int_0^1 g'(x)\eta'(x) dx
&= [ g'(x) \eta(x) ]_0^1 - \int_0^1 g''(x)\eta(x) dx\\
&= 54 \int_0^1 \eta(x) dx - 162\int_{1/3}^{2/3}\eta(x)dx\\
&= 54 Q(\eta) - 162 C(\eta)
\end{align}
$$
Since $\eta \in Y_0$, $Q(\eta) = C(\eta) = 0$ and the cross term goes away. As a result,
$$P(f) = P(g) + P(\eta) \ge P(g)$$
because $P(\eta)$ is non-negative. Together with $Q(f) = Q(g) = 2$, we get
$$\frac{P(f)}{Q(f)^2} \ge \frac{P(g)}{Q(g)^2} = \frac{108}{2^2} = 27$$
As a result,
$$\min\left\{ \frac{P(f)}{Q(f)^2} : f \in X, C(f) = 0 \right\} =
\min\left\{ \frac{P(f)}{Q(f)^2} : f \in Y_2 \right\} = 27$$