The idea is that $A$ is the orthogonal complement of the indicator function ${\bf 1}_{[a,b]}$ of $[a,b]$, so $A^\perp$ is the span of ${\bf 1}_{[a,b]}$. But the latter intersects $X$ only in the zero function because ${\bf 1}_{[a,b]}$ is not smooth (continuous).
The details read as follows: Let $X:=(C_0^\infty(\mathbb R),\langle\cdot,\cdot\rangle_{L^2})$ and $A:=\{g\in X:\int_a^bg(x)dx=0\}$. Note that $A$ can be re-written as
\begin{align*}
A&=\Big\{g\in X:\int_{\mathbb R}{\bf 1}_{[a,b]}g(x)dx=0\Big\}\\
&=\{g\in X:\langle{\bf 1}_{[a,b]},g\rangle_{L^2}=0\}\\
&=\{g\in L^2(\mathbb R):\langle{\bf 1}_{[a,b]},g\rangle_{L^2}=0\}\cap X=\{{\bf 1}_{[a,b]}\}^{\perp,L^2}\cap X\,.
\end{align*}
where $(\cdot)^{\perp,L^2}$ is the orthogonal complement in $\bf L^2$.
Now we want to show that the orthogonal complement of $A$ in $\bf X$ (i.e. $A^\perp=A^{\perp,L^2}\cap X$) is just the zero function.
For this we need the following facts (in this order):
With these tools at hand we compute
\begin{align*}
A^\perp=A^{\perp,L^2}\cap X&=(\{{\bf 1}_{[a,b]}\}^{\perp,L^2}\cap X)^{\perp,L^2}\cap X\\
&=\big(\overline{\{{\bf 1}_{[a,b]}\}^{\perp,L^2}\cap X}\big)^{\perp,L^2}\cap X\\
&=(\{{\bf 1}_{[a,b]}\}^{\perp,L^2})^{\perp,L^2}\cap X\\
&=\operatorname{span}({\bf 1}_{[a,b]})\cap X=\{0\}
\end{align*}
so altogether $A^\perp=\{0\}$. The last step is where we used that ${\bf 1}_{[a,b]}\not\in X$.