Assume that $f : H \to H$ is distance preserving.
Define $T : H \to H$ as $$Tx = f(x) - f(0), \quad\forall x\in X$$ We obviously have $T0 = 0$.
$T$ is distance preserving:
$$\|Tx - Ty\| = \|(Tx - f(0)) - (Ty - f(0))\| = \|f(x) - f(y)\| = \|x - y\|, \quad\forall x, y \in H$$
Since $T0 = 0$, $T$ also preserves the norm.
$$\|Tx\| = \|Tx - T0\| = \|x - 0\| = \|x\|, \quad\forall x \in H$$
Furthermore, $T$ preserves the inner product:
\begin{align}
0 &= \|Tx - Ty\|^2 - \|x- y\|^2 \\
&= \langle Tx - Ty, Tx - Ty\rangle - \langle x -y, x-y\rangle\\
&= \|Tx\|^2 - 2\langle Tx, Ty\rangle + \|Ty\|^2 - \|x\|^2 + 2\langle x, y\rangle - \|y\|^2 \\
&= 2(\langle Tx, Ty\rangle - \langle x, y\rangle)
\end{align}
which implies $\langle Tx, Ty\rangle = \langle x, y\rangle, \forall x,y \in H$.
Now we can show that $T$ is also linear:
$$ \|\alpha x + \beta y - z\|^2 = \|\alpha x\|^2 + \|\beta y\|^2 + \|z\|^2 - 2\langle \alpha x, z\rangle - 2 \langle \beta y, z\rangle + 2 \langle \alpha x, \beta y\rangle$$
$$ \|\alpha Tx + \beta Ty - Tz\|^2 = |\alpha|^2\|Tx\|^2 + |\beta|^2\|Ty\|^2 + \|Tz\|^2 - 2\alpha\langle Tx, Tz\rangle - 2 \beta\langle Ty, Tz\rangle + 2 \alpha\beta\langle Tx, Ty\rangle$$
Right hand sides are equal so
$$\|\alpha x + \beta y - z\| = \|\alpha Tx + \beta Ty - Tz\|, \quad\forall x,y,z \in H, \forall \alpha,\beta\in\mathbb{R}$$
In particular, for $z = \alpha x + \beta y$ we get
$$0 = \|\alpha x + \beta y - z\| = \|\alpha Tx + \beta Ty - T(\alpha x + \beta y)\|$$
which implies $T(\alpha x + \beta y) = \alpha Tx + \beta Ty, \forall x, y \in H, \forall \alpha, \beta \in \mathbb{R}$
Therefore, $T \in B(H)$ is a linear isometry and $f(x) = f(0) + Tx$, $\forall x\in H$.
Note:
Norm-preserving maps $U \in B(H)$ are usually also required to be surjective to be called isometries. In that case, $U$ is called a unitary operator and a common equivalent definition is
$$U^*U = UU^* = I$$
Your distance preserving function $f$ has to be surjective in order for $T$ above to be unitary. Namely, $\|Tx\| = \|x\|, \forall x \in X$ implies that $T$ is injective, and also $T$ is surjective since $f$ is.
Otherwise, consider $f : \ell^2 \to \ell^2$ defined as $$(x_1, x_2, \ldots ) \mapsto (0, x_1, x_2, \ldots)$$
which is distance-preserving but $T = f$ is not surjective and hence not unitary.