Let $F(w)=\dfrac{w^T D w}{w^T S w}$. Since $S$ is positive definite, the logarithm $$\log F(w)=\ln(w^T D w)-\ln(w^T S w)$$ is well-defined and so the condition $0=\dfrac{\partial F}{\partial w}=F(w)\dfrac{\partial}{\partial w}\left(\log F\right)$ is satisfied if either $F(w)$ or $\dfrac{\partial}{\partial w}\left(\log F\right)$ vanish. For the first case, we need $w^T D w=0$; the second requires
$$\dfrac{\partial}{\partial w}\left(\log F\right)=\dfrac{\partial}{\partial w}\left(\log w^T D w\right)-\dfrac{\partial}{\partial w}\left(\log w^T S w\right)=\dfrac{2Dw}{w^T D w}-\dfrac{2Sw}{w^T S w}=0$$
which implies $Dw (w^T S w)=(S w)w^T D w$.
This is the same condition found by Omnomnomnom, but I'll provide a different suggestion. Observe that the minimization condition and the definition of $F(w)$ together imply
$$(Dw)w^T D w=F(Dw)w^T S w=F(Sw)w^T D w$$ which means that either $w^T D w=0$ (the first condition found earlier) or $(D-F S)w=0$. In the former case the objective function is minimized by finding $F(z)$ such that $F(z)=w^T D w=0$. In the latter, we minimize by finding $F$ such that $D-FS$ has a null eigenvector $w$.