This is an expanded version of my comment:
Let $\{\phi_n\}_1^\infty$ and $\{\lambda_n\}_1^\infty$ be the eigenfunctions and eigenvalues of $-\Delta$ on $U$, and project all functions involved onto the orthonormal basis:
\begin{align}
u_n(t):=(u(t,x),\phi_n(x)),\\
g_n:=(g(x),\phi_n(x)),\\
f_n(t):=(f(t,x),\phi_n(x)).
\end{align}
The $f_n$'s are $\tau$-periodic, and by completeness of the basis, it suffices to consider whether the $u_n$'s are $\tau$-periodic as well.
The $u_n$'s solve the initial value problems
$$
u_n'(t)+\lambda_n u_n(t)=f_n(t),\\
u_n(0)=g_n,
$$
which have the solutions
$$
u_n(t)=e^{-\lambda_n t}g_n+\int_0^te^{-\lambda_n(t-s)}f_n(s)ds.
$$
We have $\tau$-periodicity if and only if $u_n(t+\tau)=u_n(t)$. Substituting the solution into this expression, extending $f_n$ to $\mathbb R$ using periodicity, and changing variables $s\to s+\tau$ in the integral yields the equation
$$
e^{-\lambda_n(t+\tau)}g_n+\int_{-\tau}^te^{-\lambda_n(t-s)}f_n(s)ds=e^{-\lambda_nt}g_n+\int_{0}^te^{-\lambda_n(t-s)}f_n(s)ds,
$$
which reduces to
\begin{align}
(e^{-\lambda_n\tau}-1)g_n&=-\int_{-\tau}^0e^{\lambda_ns}f_n(s)ds\\
&=-e^{-\lambda_n \tau}\int_0^\tau e^{\lambda_n s}f_n(s)ds.
\end{align}
Since $\lambda_n>0$ for all $n$, we conclude that
$$
g_n=\frac{1}{e^{\lambda_n\tau}-1}\int_0^\tau e^{\lambda_n s}f_n(s)ds.
$$