After asking this question, it would be nice to know if some generalized version of it is also valid:
Firstly, is the following claim true: Let $M$ be a uniform topological space, $S$ a dense subset of $M$, and $f : S \to M$. If $f$ is uniformly continuous and $M$ is complete, then there exists a unique continuous extension of $f$ to $M$. Furthermore, this extension is uniformly continuous.
Secondly, if the above claim is true, then my question is: If we know that actually $f:S \to S$ and $f$ is an automorphism of finite order $d$, and if we also know that the unique continuous extension $F: M \to M$ is an automorphism, is it true that $F$ must be of order $d$?
(The idea to replace a metric space by a uniform space is thanks to the comments in this question).
Remark: I think that if the above claim is true, then the same argument as in the first answer should also work here, so my question has a positive answer.
Moreover, in case my question has a positive answer, is it possible to further generalize it (with $M$ a topological space, which is not necessarily uniform?).