[proofplan]
We prove directly from the definition of an ideal. First we note that $I^\perp$ is a linear subspace of $\mathfrak g$ because it is defined by homogeneous linear equations. Then, for $x \in I^\perp$ and $g \in \mathfrak g$, we test the bracket $[g,x]$ against an arbitrary element $i \in I$. Invariance and symmetry move the bracket from $[g,x]$ onto $[i,g]$, which lies in $I$ because $I$ is an ideal; orthogonality of $x$ to $I$ then gives the desired vanishing.
[/proofplan]
[step:Verify that $I^\perp$ is a linear subspace of $\mathfrak g$]
Let $x,y \in I^\perp$ and let $a,b \in k$. For every $i \in I$, bilinearity of $B$ gives
\begin{align*}
B(ax+by,i)=aB(x,i)+bB(y,i)=a \cdot 0+b \cdot 0=0.
\end{align*}
Therefore $ax+by \in I^\perp$, so $I^\perp$ is a linear subspace of $\mathfrak g$.
[/step]
[step:Show that bracketing an element of $I^\perp$ by an element of $\mathfrak g$ stays orthogonal to $I$]
Let $x \in I^\perp$ and let $g \in \mathfrak g$. Define
\begin{align*}
y := [g,x] \in \mathfrak g.
\end{align*}
To prove $y \in I^\perp$, let $i \in I$ be arbitrary. By symmetry of $B$, followed by invariance of $B$ applied to the triple $(x,i,g)$, we have
\begin{align*}
B(y,i)
&= B([g,x],i) \\
&= B(i,[g,x]) \\
&= B([i,g],x) \\
&= B(x,[i,g]).
\end{align*}
Since $I \trianglelefteq \mathfrak g$ and $i \in I$, $g \in \mathfrak g$, the ideal property gives $[i,g] \in I$. Because $x \in I^\perp$, it follows that
\begin{align*}
B(x,[i,g])=0.
\end{align*}
Hence $B(y,i)=0$ for every $i \in I$, so $y=[g,x] \in I^\perp$.
[/step]
[step:Conclude that $I^\perp$ is an ideal]
We have shown that $I^\perp$ is a linear subspace of $\mathfrak g$ and that
\begin{align*}
[g,x] \in I^\perp
\end{align*}
for every $g \in \mathfrak g$ and every $x \in I^\perp$. This is precisely the condition $[\mathfrak g,I^\perp] \subseteq I^\perp$, so $I^\perp \trianglelefteq \mathfrak g$.
[/step]