Without loss of generality, assume $\|g\|=1$. Then
$$
\begin{align}
0
&=\delta\int_0^1g(x)^2\,\mathrm{d}x\\
&=2\int_0^1g(x)\,\delta g(x)\,\mathrm{d}x\tag1
\end{align}
$$
For each $\delta g(x)$ that satisfies $(1)$, we want
$$
\begin{align}
0
&=\delta\int_0^1g'(x)^2\,\mathrm{d}x\\
&=2\int_0^1g'(x)\,\delta g'(x)\,\mathrm{d}x\\
&=-2\int_0^1g''(x)\,\delta g(x)\,\mathrm{d}x\tag2
\end{align}
$$
To satisfy $(2)$ for all $\delta g(x)$ that satisfy $(1)$, we must have
$$
g''(x)=\lambda g(x)\tag3
$$
for some constant $\lambda$.
Explanation of $\boldsymbol{(3)}$
Let $\lambda$ be so that
$$
\int_0^1g(x)g''(x)\,\mathrm{d}x=\lambda\int_0^1g(x)^2\,\mathrm{d}x
$$
Then, since
$$
\int_0^1g(x)\overbrace{(g''(x)-\lambda g(x))}^{\delta g(x)}\,\mathrm{d}x=0
$$
our condition says that
$$
\int_0^1g''(x)\overbrace{(g''(x)-\lambda g(x))}^{\delta g(x)}\,\mathrm{d}x=0
$$
Subtract $\lambda$ times the former from the latter to get
$$
\int_0^1(g''(x)-\lambda g(x))^2\,\mathrm{d}x=0
$$
which implies that $g''(x)=\lambda g(x)$.