First of all, three dimension is more complex so let's restrict to two dimension here. Suppose a given contour $f(x,y) = C$ is closed--I don't know how to check the closeness mathematically, but let's just assume it is. I did some experiment, three typical examples are shown below. 
By observation I have the following hypothesis about convexity if $f(x,y)$ is a polynomial: all right hand side signs are positive, and all powers of $x$ and $y$ are even. This is supported by the counter examples in the middle and the right panel. But I am not sure if it is actually true.
A directly related question would be to generalize to arbitrary function $f(x,y)$.
Edit: I should add that what I mean is the convexity of the region within the contour. I guess the question is better changed to "determine whether the region inside a contour: $f(x,y)<=C$, is convex". I apologize for not expressing it clearly.
Let suppose $f$ is enough nice function, such that we can locally rewrite the curve $f(x,y)=C$ as graph of $y=g(x)$ for some $g$ around the point $(x_0, g(x_0))$ such that $f(x_0, g(x_0))=C$. We can do this taking into account implicit function theorem! Then it is easy to check that the graph of $y=g(x)$ is convex subset of $R^2$ if and only if $g$ is linear function, i.e. $y=ax+b$ !