NopeThe answer is no. Take $H$ any topological group, $G=H\times\mathbb{Z}/2$,$H'$ another topological group having a noncentral element $a$ the generator$a'$ of order 2, $\mathbb{Z}/2$ and$G=H\times H'$, $f=g\times id_{\mathbb{Z}/2}$$a=1_H\times a'$ and $f=h\times inv_{H'}$ where $g$$h$ is any endomorphismanti-automorphism of $H$ and $inv_{h'}$ is the map $h'\mapsto h'^{-1},h'\in H'$.