Let $\mathbb U$ be the unit disk. If $D$ is simply-connected, there is a holomorphic bijection $\phi:\mathbb U\to D$ that fixes the origin, and an application of the Schwarz lemma to $\phi^{-1}\circ f\circ \phi$ gives the result.
For general $D$ (provided $\mathbb C\setminus D$ has at least $2$ points) there is a holomorphic covering map $\phi:\mathbb U\to D$ that fixes the origin. The composition $\phi^{-1}\circ f\circ \phi$ has a single-valued branch in $\mathbb U$ by the Monodromy theorem. We can pick the branch fixing $0$. Again, an application of the Schwarz lemma to $\phi^{-1}\circ f\circ \phi$ gives the result.
But I'm afraid the previous paragraph uses too much machinery. Here is a more analytic approach, via Green's function. Let $g_D(z,0)$ be Green's function of $D$ with the pole at $0$; this means
- $g_D $ is harmonic and negative in $D\setminus \{0\}$
- $g_D(z,0)-\log |z|$ is bounded near $0$, hence harmonic in $D$.
- $g_D(z,0)\to 0$ as $z\to \partial D$, except maybe for some (negligible) polar set.
Observe that $g_D$ is subharmonic in $D$. So is its composition with $f$, namely $g_D(f(z),0)$. Consider
$$u(z)=g_D(f(z),0)-g_D(z,0)$$
Since $f(z)=z+o(|z|)$, the function extends to $0$ by continuity, with $u(0)=0$ (logarithmic terms and constant term in the expansion of $g$ cancel). If $f$ turns into $0$ elsewhere in $D$, the function $u$ will have logarithmic poles there. But at any event, it is subharmonic in $D$ and $\limsup u(z)\le 0$ as $z\to \partial D$, except maybe for some polar set. Indeed, $g_D(f(z),0)<0$ in $D$, while $g_D(z,0)$ has the boundary behavior described in item 3 above.
Thus, $u\le 0$ in $D$ by the maximum principle. Since $u(0)=0$, said principle implies $u\equiv 0$. Therefore, $f$ maps every level curve $g_D(z,0)=c$ into itself. For sufficiently large (negative) $c$, this curve is a small almost-circle around $0$, due to the logarithmic pole. It bounds a Jordan domain which $f$ must map onto itself. Now the simply-connected case applies and yields $f(z)\equiv z$ in a neighborhood of $0$, hence everywhere in $D$ by the identity theorem.
Phew. Did someone say "too much machinery"? By the way, the inequality $u\le 0$ is a form of the Lindelöf principle.