There might be no solution. In fact, it is possible to write a necessary and sufficient condition for its existence.
First of all, we need to assume that $\int_{\mathbb R} |v| \, w(v) dv<\infty$.
When $q(0)=0$, then it is obvious that $(*)$ has a solution iff $\int_{\mathbb R} v\, w(v) dv \ge 0$ (since we must have $f(1,v) = w(v)$ a.e.). Similarly, if $q(1) = 0$, then $(*)$ has a solution iff $\int_{\mathbb R} v\, w(v) dv \le 0$.
Let us study the case $q(0)\cdot q(1) >0$. Let $F^{-1}(z)$ be the quantile function corresponding to $w$, i.e. $$F^{-1}(z) = \inf\left\{x\in \mathbb{R}: \int_{-\infty}^x w(v) dv\ge z\right\},\quad z\in(0,1).$$
Claim If $q(0)\cdot q(1) >0$, then $(*)$ has a solution iff
$$\int_{-\infty}^{A}v\, w(v) dv\le 0 \tag{$\le$}$$
and
$$\int_{A}^\infty v\, w(v) dv\ge 0 \tag{$\ge$},$$
where $A= F^{-1} (q(0))$.
Proof. Let $(\le)$ fail, i.e.
$$\int_{-\infty}^{A}v\, w(v) dv >0.$$
Then, clearly, $A>0$ and
$$
\int_{-\infty}^{\infty} v\, f(0,v) dv \ge \int_{-\infty}^A v\,f(0,v) dv + A \int_A^\infty f(0,v) dv \\
\overset{(2)}{=}
\int_{-\infty}^{A} v f(0,v) dv + Aq(0)- A \int_{-\infty}^A f(0,v) dv = Aq(0) + \int_{-\infty}^{A} (v-A) f(0,v) dv \\
= Aq(0) - \int_{-\infty}^{A} \int_v^A du\, f(0,v) dv = A\int_{-\infty}^A w(v) dv - \int_{-\infty}^A \int_{-\infty}^u f(0,v) dv\,du \\
\ge A\int_{-\infty}^A w(v) dv - \int_{-\infty}^A \int_{-\infty}^u w(v) dv\,du = A\int_{-\infty}^A w(v) dv + \int_{-\infty}^A (v-A) w(v) dv \\
= \int_{-\infty}^A v\,w(v) dv>0,
$$
so $(4)$ fails.
Similarly, if $(\ge)$ fails, then so does $(3)$.
On the other hand, if both $(\le)$ and $(\ge)$ hold, then
$$
f(0,v) = w(v) \mathbf{1}_{(-\infty, A)}(v), \quad f(1,v) = w(v) \mathbf{1}_{[A, +\infty)}(v) \tag{$f$}
$$
are easily seen to satisfy $(*)$.
Remarks
- There's no need to consider the case $q(0)\cdot q(1) = 0$ individually: in this case $A$ is either $-\infty$ or $+\infty$, so one of $(\le)$ and $(\ge)$ holds trivially, and we need just another one, as it is written above.
- Where do $(\le)$ and $(\ge)$ come from? In fact, $(f)$ gives the decomposition $w(v) = f(0,v) + f(1,v)$ satisfying (2) and such that $\int_{\mathbb R} v f(0,v) dv$ is minimal (correspondingly, $\int_{\mathbb R} v f(1,v) dv$ is maximal).
- It is easy to see that the solution is unique iff at least one of $(\le)$ or $(\ge)$ is equality.
- Similarly, one can write a necessary and sufficient condition in the case where the corresponding distribution does not have a density (naturally, $(*)$ needs to be adapted correspondingly). Namely, denoting the corresponding (right-continuous) cdf by $F$, $(\le)$ and $(\ge)$ transform to
$$
\int_{(-\infty, A)} v\, dF(v) + A \cdot\big(q(0) - F(A-)\big)\le 0
$$
and
$$
\int_{(A, \infty)} v\, dF(v) + A\cdot \big(F(A) - q(0)\big)\ge 0.
$$