Continuous time
Since the signal is given to be periodic with period $T$, it has a Fourier series. The DC value is given by
$$c_0 = \frac 1T \int_0^T x(t) \,\mathrm dt = \frac 1T \int_{t_0-T}^{t_0} x(t)\,\mathrm dt \tag{1}$$
(any arbitrary starting point $t_0$ is acceptable as long as the integral is over a $T$-second interval. Now, if we define an LTI system whose impulse response is $h(t) = \begin{cases}\frac 1T, & 0 \leq t \leq T,\\0,&\text{elsewhere}, \end{cases}$, then at any given time $t_0$, the output $y$ of this LTI system (when the input to this LTI system is the periodic signal $x(t)$) is given by
\begin{align}
y(t_0) &= \int_{-\infty}^\infty h(t_0-t)x(t) \,\mathrm dt\tag{2}\\
&= \int_{t_0-T}^{t_0} h(t_0-t)x(t) \,\mathrm dt\tag{3}\\
&=\frac 1T \int_{t_0-T}^{t_0} x(t)\,\mathrm dt \tag{4}\\
&= c_0
\end{align}
where in going from $(2)$ to $(3)$ we have used the fact that $h(t_0-t)$ equals $0$ whenever its argument $t_0-t$ exceeds $T$ (that is, $t < t_0-T$) or is smaller than $0$ (that is, $t > t_0$), and in going from $(3)$ to $(4)$, we have substituted the value $\frac 1T$ for $h(t_0-t)$.
Thus, when the periodic signal $x(t)$ is the input to an LTI system with impulse response $h(t)$ defined above, the output has value $c_0$ for all $t, -\infty < t < \infty$.
Discrete time
The result is essentially similar except that we have to be a bit more careful with endpoints.
If $x[\cdot]$ is a discrete-time sequence with period $N$, then its DC value is $X[0]$ where $X[\cdot]$ denotes the Discrete Fourier Transform of $x[\cdot]$. Thus,
$$X[0] = \frac 1N \sum_{n=0}^{N-1} x[n] = \frac 1N \sum_{n=n_0-(N-1)}^{n_0} x[n]\tag{5}$$
is the sum of $N$ consecutive elements of $x[\cdot]$ and the second sum in $(5)$ can be recognized as the first sum with its terms re-arranged. So, if we set $h[n] = \begin{cases}\frac 1N, & 0 \leq n < N,\\0,&\text{elsewhere}, \end{cases}$ as the unit pulse response of a discrete-time LTI system, then at time $n_0$, the output $y$ of this LTI system, when driven by the periodic discrete-time signal $x[\cdot]$, is given by
\begin{align}
y[n_0] &= \sum_{n=-\infty}^\infty h[n_0-n]x[n] \tag{6}\\
&= \sum_{n=n_0 - (N-1)}^{n_0} h[n_0-n]x[n]\tag{7}\\
&=\frac 1N \sum_{n=n_0 - (N-1)}^{n_0} x[n] \tag{8}\\
&= X[0]
\end{align}
where in going from $(6)$ to $(7)$ we have used the fact that $h[n_0-n]$ equals $0$ whenever its argument $n_0-n$ exceeds $N-1$ (that is, $n < n_0-(N-1)$) or is smaller than $0$ (that is, $n > n_0$), and in going from $(7)$ to $(8)$, we have substituted the value $\frac 1N$ for $h(n_0-n)$.
And that's all there is to it, folks. The LTI system whose output in response to a periodic input signal of period $T$ (continuous time) or $N$ (discrete time) is the DC value of the signal at all time instants is a moving-average filter. At any specific time instant, the filter output is just the average of the continuous-time periodic input signal over the past $T$ seconds. or the average of the discrete-time periodic input signal over the current and the immediately-past $N-1$ samples, depending on which case one is considering.
Edited to address some of the criticisms in the comments following this question
Are the LTI systems described above unique? Well, No and Yes.
NO, because (i) a signal of period $T$ (or $N$) is also a periodic signal of period $kT$ (or $kN$) where $k$ is a positive integer and so we could average over intervals of length $kT$ (or $kN$) if we choose to do so, and (ii) we could insert a delay into the LTI system described above and still get the same boring constant DC value as the output for all time.
Yes, if in addition, we insist on the filter being as short as possible and having as little delay as possible.
As long as the input signal $x$ satisfies
$$x(t+T) = x(t) ~ \forall \, t, -\infty < t < \infty,\tag{9}$$
or
$$x[n+N] = x[n] ~ \forall \, n, -\infty < n < \infty,
\tag{10}$$
the proposed solution provides the shortest filter with the least delay with the property that the filter response to $x$ is the DC value of the signal at all time instants.
What if $(9)$ and $(10)$ hold only for $t, T, N \geq 0$ and $x$ is $0$ for negative arguments? Well, the filter proposed here has a start-up transient in the output, but the output settles down to the DC value once one full period of $x$ has been observed and stays there for ever afterwards.
I will ignore comments re best estimators in presence of AWGN etc. There is no estimation being done here, and noise is not an issue.
Finally, I wish to comment on the solution provided in the accepted answer (written by MattL) which is that any low-pass filter with the property that its frequency response has value $1$ at $f=0$ and value $0$ at all nonzero integer multiples of $\frac 1T$ will do. As MattL points out, there are infinitely many filters with this property, but the (causal) filter with the shortest impulse response and least delay is the one described here. To see this, recall the concept of a Nyquist pulse which is defined in the time domain as a signal that has value $1$ at $t=0$ and value $0$ at nonzero multiples of $T$. There are infinitely many Nyquist pulses but the one with the smallest bandwidth is $\operatorname{sinc}\left(\frac tT\right)$ whose Fourier transform is $T\cdot \operatorname{rect}(Tf)$ giving a bandwidth of $\frac{1}{2T}$.
MattL's solution is any filter whose frequency response is a Nyquist pulse in the frequency domain. Applying duality, the filter with the shortest impulse response is the one whose frequency response is $\operatorname{sinc}(Tf)$, the frequency-domain Nyquist pulse, and this impulse response must be $\frac 1T \operatorname{rect}\left(\frac tT\right)$ which is a rectangular pulse of duration $T$ and amplitude $\frac 1T$, as described in the solution given in this answer. So, yes, any filter whose frequency response is a (frequency-domain) Nyquist pulse will provide an output that at all times equals the DC value of the signal, but the filter with the filter with the least delay and shortest impulse response is as described above.