Let us fix an integer $n \ge 2$ (the following results are not restricted to odd numbers). The function
$$
F(x_1, \ldots, x_n) = (x_1^2 + x_2^2)(x_2^2 + x_3^2) \cdots (x_n^2 + x_1^2)
$$
is continuous on the compact set
$$
K = \{ x \in \Bbb R_{\ge 0}^n \mid \sum_{k=1}^n x_k = n \}
$$
and therefore attains its maximum at some point $a =(a_1,\ldots, a_n) \in \Bbb R_{\ge 0}^n$:
$$ \tag{M}
f(n) = \max \{ F(x) \mid x \in K \} = F(a) \, .
$$
The idea is to show that
$$ \begin{aligned}
a &= (0, 2, 0, 2, \ldots, 0, 2) \quad\text{if $n$ is even,} \\
a &= (0, 2, 0, 2, \ldots, 0, 3/2, 3/2) \quad \text{if $n$ is odd.}
\end{aligned} \tag{*}
$$ or a cyclic permutation thereof.
It then follows that
$$
f(n) = \begin{cases}
2^{2n} & \quad\text{if $n$ is even,} \\
2^{2n-11} \cdot 3^6 & \quad\text{if $n$ is odd.}
\end{cases}
$$
The proof of $(*)$ is done in several steps. In each step some property of the “maximal vector” $a$ is obtained. This is always done by showing that if $a$ does not have this property then there is another vector $\tilde a$ with the same sum of its components, and $F(\tilde a) > F(a)$, in contradiction to the maximality condition $(M)$.
Step 1:
$$
a_k > 0 \quad \implies \quad a_{k-1} < a_k \text{ or } a_{k+1} < a_k \,.
$$
In particular, $ \min(a_1, \ldots, a_n) = 0$.
Roughly speaking: a nonzero component cannot be a “local minimum.”
Proof: Assume that $\min(a_{k-1}, a_{k+1}) \ge a_k > 0$. (Here and in the following, all index calculations are done $\bmod n$.) Then
$$
(a_{k-1}^2 + a_k^2)(a_k^2 + a_{k+1}^2) \le (a_{k-1}^2 + a_{k-1} a_k)(a_k a_{k+1} + a_{k+1}^2) \\
< (a_{k-1} + \frac 12 a_k)^2 (a_{k+1} + \frac 12 a_k)^2
$$
so that
$$
F(\ldots, a_{k-1}, a_k, a_{k+1},\ldots) <
F(\ldots, a_{k-1} + \frac 12 a_k, 0, a_{k+1} + \frac 12 a_k, \ldots)
$$
in contradiction to the maximality condition $(M)$.
Step 2: $$
\begin{aligned}
&0 = a_{k-1} < a_k \le a_{k+1} \le a_{k+2} \quad \text{or} \\
&a_k \ge a_{k+1} \ge a_{k+2} > a_{k+3} = 0
\end{aligned}
$$
does not hold for any index $k$.
In other words: a zero component cannot be followed by three increasing nonzero components, or preceded by three decreasing nonzero components.
Proof: Assume that $0 = a_{k-1} < a_k \le a_{k+1} \le a_{k+2}$. Then
$$
a_k^2 ( a_k^2+ a_{k+1}^2)(a_{k+1}^2 + a_{k+2}^2)
= a_k^4 a_{k+1}^2 + a_k^4 a_{k+2}^2 + a_k^2 a_{k+1}^4 + a_k^2 a_{k+1}^2 a_{k+2}^2 \\
\le a_k^4 a_{k+2}^2 + 3 a_k^2 a_{k+1}^2 a_{k+2}^2
< (a_k + a_{k+1})^4 a_{k+2}^2
$$
so that
$$
F(\ldots, 0, a_k, a_{k+1},a_{k+2}, \ldots) <
F(\ldots, 0, a_k + a_{k+1}, 0, a_{k+2}, \ldots)
$$
in contradiction to the maximality condition $(M)$.
Step 3: At most two consecutive components $a_k$ are nonzero.
Proof: Let $a_k, \ldots, a_{k+l-1}$ be a maximal range of $l$ consecutive nonzero components of $a$:
$$
\begin{aligned}
a_{k-1} &= 0 \\
a_j &> 0 \quad \text{for $j=k, \ldots, k+l-1$}, \\
a_{k+l} &= 0
\end{aligned}
$$
Let $m \in \{ k, \ldots, k+l-1 \}$ be an index where the maximum of those components is attained:
$$
a_m = \max \{ a_k, \ldots, a_{k+l-1} \} \, .
$$
From Step 1 it follows that the components are (weakly) increasing up to $a_m$, and (weakly) decreasing after $a_m$:
$$
0 = a_{k-1} < a_k \le a_{k+1} \le \ldots \le a_{m-1}\le a_m \\
\ge a_{m+1} \ge \ldots \ge a_{k+l-1}
> a_{k+l} = 0 \, .
$$
From Step 2 it then follows that $a_m$ is preceded and followed by at most one nonzero component, which means that $l \le 3$.
It remains to exlude the case $l=3$: Assume that
$$
0 = a_{k-1} < a_k \le a_{k+1} \ge a_{k+2} >a_{k+3} = 0 \, .
$$
Then
$$
a_k^2 ( a_k^2 + a_{k+1}^2) < (a_k + \frac 12 a_{k+1})^4 \, ,\\
(a_{k+1}^2 + a_{k+2}^2) a_{k+1}^2 < (a_{k+2} + \frac 12 a_{k+1})^4 \, ,
$$
so that
$$
F(\ldots, 0, a_k ,a_{k+1},a_{k+2},0,\ldots)
< F(\ldots,0, a_k + \frac 12 a_{k+1},0, a_{k+2} + \frac 12 a_{k+1}, 0, \ldots) \, .
$$
So up to now we have shown that the components of $a$ consist of “blocks,” starting with zero and followed by one or two nonzero components. These blocks can be rearranged without changing the value $F(a)$. Therefore we can assume that $a$ consists of zero or more “2-blocks” followed by zero or more “3-blocks:”
$$
a = (0, u_1, \ldots, 0, u_N, 0, v_1,w_1, \ldots, 0, v_M, w_M)
$$
Step 4: $v_j = w_j$ in each 3-block.
Proof: If $v_j \ne w_j$ then
$$
v_j^2(v_j^2 + w_j^2)w_j^2 < 2 \left( \frac{v_j+w_j}2 \right)^6
$$
so that $F(a)$ increases if the block $(0,v_j,w_j)$ is replaced by $(0,\frac{v_j+w_j}2,\frac{v_j+w_j}2)$.
Step 5: All 3 blocks are identical: $v_1 = \ldots = v_M$.
Proof: Each 3 block contributes $2v_j^6$ to the product $F(a)$. The total contribution of all 3-blocks is
$$
2^M (v_1 \cdots v_M)^6 \le 2^M \left( \frac{v_1 + \ldots + v_M}{M}\right)^{6M}
$$
with equality if and only if all $v_j$ are equal (AM-GM inequality).
Step 6: There is at most one 3-block.
Proof: Replacing two 3-blocks
$$
(0,v, v, 0,v, v)
$$
by three 2-blocks
$$
(0,u,0,u,0, u)
$$
with $u = \frac 43 v$ preserves the sum of the components, but increases the value of $F(a)$.
Step 7: All 2-blocks are identical: $u_1 = \ldots = u_N$.
The proof is identical to that of Step 5.
Finale: For even $n$ we are done. $a$ consists only of (identical) 2-blocks, and the sum of the components is $n$, i.e.
$$
a = (0, 2, 0, 2, \ldots , 0,2) \,.
$$
If $n$ is odd then $(n-3)/2$ 2-blocks are followed by a single 3-block
$$
a = (0,u,0,u,\ldots,0, v, v) \quad \text{where }\frac{n-3}{2}u + 2v = n \, .
$$
Then
$$
F(a) = 2 u^{2n-6}v^6 = 2 \left(\frac 43 \right)^{2n-6} \left(\frac 34 u\right)^{2n-6}v^6 \, .
$$
The AM-GM inequality shows that
$$
\left(\frac 34 u\right)^{2n-6}v^6 \le \left( \frac{(2n-6)\frac 34 u + 6 v}{2n}\right)^{2n}
= \left( \frac{3n}{2n}\right)^{2n} = \left( \frac{3}{2}\right)^{2n} \, .
$$
with equality if and only if $\frac 34 u = v$. It follows that $u=2$ and $v= \frac 32$ for the maximal vector $a$, i.e.
$$
a = (0,2,0,2,\ldots,0, 3/2, 3/2) \, ,
$$
and that finishes the proof of $(*)$.