You can switch $F$ and the infinite series because the series converges in the space of tempered distributions $\mathscr S’(\mathbb R)$ and $F$ is continuous and linear from $\mathscr S’(\mathbb R)$ to itself.
Why is the series converging in $\mathscr S’(\mathbb R)$? Well, it has to be checked of course. Take $f\in \mathscr S(\mathbb R)$, consider the quantities
$$ \int_{\mathbb R}\cos(2\pi n t/T)f(t)dt. $$
Since the Fourier transform of cosine functions are sums of two Dirac deltas, the above quantity is the same as
$$ \frac{F(f)(2\pi n t/T)+ F(f)(-2\pi n t/T)}{2} $$
and since the Fourier transform preserves $\mathscr S(\mathbb R)$, $F(f)$ decays fast at infinity, so that in particular the series
$$ \sum_n\int_{\mathbb R}\cos(2\pi n t/T)f(t)dt. $$
is well-defined and converges. This shows that the Fourier series you wrote is well defined and converges in $f\in \mathscr S(\mathbb R)$, so exchanging series and Fourier transform is justified from what I said above.
With this argument of testing against a Schwartz function $f\in \mathscr S(\mathbb R)$, you might as well just compute the Fourier transform of the Dirac comb directly from the definition of Fourier transform (it’s basically the same argument computationally speaking).