Let's prove that $f=g$ almost everywhere, i.e that $h:= f-g$ is equal to $0$ almost everywhere.
First, note that you have $\int_{\mathbb R^n}h\phi =0$ for all $\phi\in\mathcal C_0^\infty$ by hypothesis.
Next, let $\phi\in\mathcal C_0^\infty$ be supported on the unit ball centered at the origin, and such that $\int_{\mathbb R^n}\phi = 1 $. We can write for all $x\in\mathbb R^n$ and $r>0$ ($\mu$ is the Lebesgue measure) :
$$\begin{align}
h(x)&=h(x)\cdot\int_{\mathbb R^n} \phi({x-y})d\mu(y)\\
&=\int h(x)\phi({x-y})d\mu(y)\\
&=\frac{1}{r^n}\int h(x)\phi\left(\frac{x-y}r\right)d\mu(y)\\
&=\frac{1}{r^n}\int [h(x)-h(y)+h(y)]\phi\left(\frac{x-y}r\right)d\mu(y)\\
&=\frac{1}{r^n}\int [h(x)-h(y)]\phi\left(\frac{x-y}r\right)d\mu(y) \tag1\\
&+ \frac{1}{r^n}\int h(y)\phi\left(\frac{x-y}r\right)d\mu(y)\tag2\end{align} $$
Now, notice that because $\phi\in\mathcal C_0^\infty$, $\varphi :=\phi((x-\cdot)/r)$ is also in $C_0^\infty $ for all $r>0$. Hence the second integral $(2)$ is equal to $0$ for all $r>0$.
Finally, you have by Lebesgue's differentiation theorem that
$$\lim_{r\to0} \frac{1}{r^n}\int_{\|x-y\|\le r}|h(y)-h(x)|\ d\mu(y) = 0 $$
For almost all $x$ in $\mathbb R^n$, from which you can conclude that $(1)$ goes to $0$ as $r\to0$ (apply the triangle inequality and the boundedness of $\phi$).
By taking the limit as $r\to0$, the desired result follows.