EDIT 2: The question has been changed to ask not for a curve, but for a connected set. The below no longer applies but I am leaving it here in case others find it useful.
EDIT: The original version of the question was unclear; now that it has been clarified that one seeks a curve along which $f=0$, I believe the claim is false.
First, it is obvious that
1) The sub- and super-level sets where $f<0$ and $f>0$, respectively, are separated, and
2) The level set $f^{-1}(0)$ does not have to be a curve (consider for instance
$$f(x,y) = \begin{cases}0, &\frac{1}{4} < y < \frac{3}{4}\\4y-3, &y\geq\frac{3}{4}\\4y-1, &y \leq \frac{1}{4}.\end{cases}$$
Now your question (if I'm interpreting it correctly) is whether the zero level set contains some continuous curve. I don't think this is necessarily the case. Consider for instance the set $S$ given by two copies of the topologist's sine curve:
$$S = \left\{ \left( x,\frac{1}{2}+\frac{1}{2}\sin\frac{1}{2x-1}\right)\ \Big\vert\ x \neq \frac{1}{2}\right\} \cup \left\{\left(\frac{1}{2},y\right)\ \Big\vert\ 0 \leq y \leq 1\right\}.$$

$S$ is closed and so the distance function $d(x,y)$ of $(x,y)$ to $S$ is well-defined and continuous. Also define a sign function $\epsilon(x,y)$ to be 1 above and -1 below the sine curve, i.e.
$$\epsilon(x,y) = \begin{cases}\textrm{sign}\left(y-\frac{1}{2}-\frac{1}{2}\sin\frac{1}{2x-1}\right), &x\neq \frac{1}{2}\\0, & x = \frac{1}{2}\end{cases}$$
and set $f=\epsilon d$ to get a counterexample where $f^{-1}(0)$ is not path-connected.
(This $f$ does not exactly satisfy your boundary conditions at $y=\pm 1$, but this could be fixed by e.g. taking $f(x,y) = (\epsilon d)(x,[4y-1]/2)$ on $y\in (1/4,3/4)$ and extending appropriately.)