The keyword is "periodic decomposition problem".
A 2013 survey was written by Bálint Farkas and Szilárd Révész and can be found either on arXiv or in the ICDEA 2013 proceedings. This also discusses, among other things, measurability (as asked in the comments of the question).
In the case of the real line, if the periods $x_1,x_2,\dots,x_n\in\mathbf{R}$ have pairwise irrational quotients, I think the earlist proof is in The Sum of Periodic Functions by Mortola, Stefano and Peirone, Roberto in Bollettino dell'Unione Matematica Italiana, Volume 2-A (1999) pp. 393-396. (Seems like the link in their suggested citation is broken...) (Anyhow, this is cited in the 2013 survey as [32].)
The answer is: $f$ is the sum of periodic functions with periods $x_1,x_2,\dots,x_n$ (with pairwise irrational quotients) iff $\Delta_{x_1}\Delta_{x_2}\dots\Delta_{x_n}f=0$, where for $\alpha\in\mathbf{R}, g:\mathbf{R}\to\mathbf{R}$, we define $(\Delta_\alpha g)(x):=g(x+\alpha)-g(x)$.
Furthermore, a function $f$ is a sum of $n$ periodic functions iff there exist such $x_1,\dots,x_n$. (This is not a condition that is impossible to ever check; For example, by using the iterated mean value theorem, Mortola and Peirone also show in their paper that a polynomial of degree $n$ is a sum of $n+1$ periodic functions but not $n$ periodic functions, and that $e^x$ is not a finite sum of periodic functions.)
In general, if some of the $x_i$ may be rational multiples of others, then the answer can be found in Invariant decomposition of functions with respect to commuting invertible transformations (also on arXiv and cited in the 2013 survey as [9]). The answer is that, for any partition of $\{x_1,\dots,x_n\}$ into $B_1\cup B_2\cup\dots\cup B_m$, letting $b_i$ denote the least common multiple of $B_i$ (defined as the generator of $\bigcap_{x\in B_i}\langle x\rangle$, even if this is $\{0\}$), $\Delta_{b_1}\Delta_{b_2}\dots\Delta_{b_m}f=0$.
(Not mentioned in the survey article is restricting the domain, studied in "On sums and products of periodic functions" by Mirotin A.R. and Mirotin E.A. in Real Analysis Exchange in 2009 but not on arXiv until 2019.)