You are correct - you can only deduce that $f$ has the form of $f(x) = \frac{1}{2}x + D$ on any interval on which $f$ is not zero. A priori we can have three cases:
- Assume that $f$ doesn't have a zero. Then $f(x) = \frac{1}{2}x + D$ for all $x \in \mathbb{R}$ and has a zero - a contradiction.
- Assume that $f$ has only one zero at $x_0 \in \mathbb{R}$. Then $f$ has the form $\frac{1}{2}x + D_1$ on $(-\infty, x_0)$ and has the form $\frac{1}{2}x + D_2$ on $(x_0, \infty)$. By continuity, we must have $D_1 = D_2$ so $f$ must have the form $f(x) = \frac{1}{2}x + D$ for all $x \in \mathbb{R}$. Plugging this function back into the equation, we get
$$ \frac{x^2}{4} + Dx = \frac{x^2}{4} + Dx + D^2 + C. $$
From that, we see that the equation is satisfied with $C = -D^2$.
- Assume that $f$ has at least two zeroes. Let $x_0, x_1 \in \mathbb{R}$ be points with $f(x_0) = f(x_1) = 0$. Let us show that in this case, we must have $f(x) = 0$ for all $x_0 \leq x \leq x_1$. If we have $f(c) \neq 0$ for some $x_0 < c < x_1$, define $x_m := \inf_{x_0 < x < c} \{ f(x) \neq 0 \}$ and $x_M := \sup_{c < x < x_1} \{ f(x) \neq 0 \}$. Then, we have $f(x) \neq 0$ on $(x_m,x_M)$ and, by continuity, $f(x_m) = f(x_M) = 0$. But then, $f$ must be of the form $f(x) = \frac{1}{2}x + D$ on $[x_m,x_M]$ and so cannot vanish at both $x_m$ and $x_M$. This shows that the zero set of $f$ must be a closed interval. You can then check whether the possible explicit solutions satisfy the equation above.