Let $f:\mathbb{R}^d \to \mathbb{R}^d$ be a smooth map, and suppose there exist a matrix $C \in M_d$ such that $df(x) \in O(d)\cdot C$ for every $x \in \mathbb{R}^n$ ($O(d)$ is the orthogonal group).
Is it true $f$ must be affine?
When $C$ is invertible the answer is positive:
Define $h=f \circ C^{-1}$. Then $dh=df \circ C^{-1} \in O(d)$, so $h$ is a (Riemannian) isometry, hence affine. (so $f$ is also affine).
I do not think so. Take $\hat{f} : \mathbb{R}^2 \to \mathbb{R}^3$ parametrizing the cylinder embedded in 3D: \begin{align} \hat{x}_1 &= x_1\\ \hat{x}_2 &= \cos(x_2)\\ \hat{x}_3 &= \sin(x_2)\\ \end{align} Let $P : \mathbb{R}^3 \to \mathbb{R}^2$ be the projector $$ P : (x_1, x_2, x_3) \mapsto (x_1, x_2)$$ and form the map $$f : \mathbb{R}^3 \to \mathbb{R}^3$$
$$f(x) = \hat{f}\big(P \, x\big)$$ Then $$df(x) = \begin{pmatrix} 1 &0 & 0\\ 0 &-\sin(x_2) & 0\\ 0 & \,\,\,\,\, \cos(x_2) & 0 \end{pmatrix} = \begin{pmatrix} 1 &0 & 0\\ 0 &-\sin(x_2) & \cos(x_2)\\ 0 & \,\,\,\,\, \cos(x_2) & \sin(x_2) \end{pmatrix} \begin{pmatrix} 1 &0 & 0\\ 0 &1 & 0\\ 0 &0 & 0 \end{pmatrix}$$
However, such map seems to arise from an isometric immersion. Take the kernel of $C$, call it $V = \ker(C)$. Take its orthogonal complement $W \perp V$. Set $\dim(V) = d_0$ and $\dim(W) = d_1 = d-d_0$. Let $C_0$ be the matrix formed by vector columns that are orthonormal basis of $V$. Then $C\, C_0 = 0$ and $\text{rank}(C_0) = d_0$. Then $\mathbb{R}^{d_0}$ acts as a group on $\mathbb{R}^d$ by $x \mapsto x + C_0 v$ for $v \in \mathbb{R}^{d_0}$. One can check that $f\big(x + C_0v\big) = f(x)$. Therefore, there exists a smooth map $\hat{f} : W \to \mathbb{R}^d$ such that $f = \hat{f}\circ P_W$, where $P_W : \mathbb{R}^d \to W$ is the orthogonal projector. Therefore, on $W$ we can define $\hat{f}\circ \Big(C|_W\Big)^{-1} : W \mapsto \mathbb{R}^d$ is an isometric immersion. At least it seems to me. I didn't check everything in detail, but maybe this can be helpful even if I have made some mistake somewhere.