Let $f(x) = \cos (1-|x|^2).$ Then $f$ attains a maximum at each point of $S.$ But $\nabla f (x) = 2\sin(1-|x|^2)x$ for all $x.$ Thus $x, \nabla f (x),$ are never independent at any point of $\mathbb R^3.$
Added later: Dominique asked the question: What if the maximum is isolated? That's a good question, and we can obtain the result for this case. Suppose $f$ has an isolated maximum at $p_0\in S.$ Choose a smooth injective curve $p(t):(-1,1) \to S$ such that $p(0) = p_0.$ (For example, let $u$ be a unit vector perpendicular to $p_0.$ Then $p(t) = (\cos t)p_0 + (\sin t)u$ would do nicely.) Because $p(t)$ is a curve in $S,$ $p'(t)\perp p(t)=0$ for all $t.$
Set $g(t)= f(p(t)).$ Then $g$ has an isolated maximum at $t=0.$ Therefore $g$ is not constant, hence $g'(s)\ne 0$ for some $s\in (-1,1).$ But note
$$g'(t) = \nabla f (p(t))\cdot p'(t),\, t\in (-1,1).$$
So at $s,$ $\nabla f (p(s))$ is not perpendicular to $p'(s),$ while $p(s)$ is perpendicular to $p'(s).$ Thus $\nabla f (p(s))$ is not a scalar multiple of $p(s)$ and we conclude $\nabla f (p(s))$ and $p(s)$ are linearly independent.