Solution 1:

I believe there are two questions asked here, not just one. Namely:

Question 1. Given two points $x,y$ in a separable compact Hausdorff space $X$, can we find two open sets $V,U$ in $X$ and a continuous function $f:X\to\mathbb R$ satisfying the conditions given by the OP.

Question 2. Given two points $x,y$ in a compact Hausdorff space $X$, can we find two open sets $V,U$ in $X$ and a continuous function $f:X\to\mathbb R$ satisfying the conditions given by the OP. (That is, in this version the space $X$ is not required to be separable.)

Accordingly, I give two answers.

Question 1. Answer yes (and it is enough to assume $X$ is ccc).

Question 2. Answer no, not necessarily. (For example the answer is no for $X=H^*$, the remainder of the Stone-Cech compactification of the half-line $[0,\infty)$, although it is yes for $X=[0,\omega_1]$, as explained in more detail below.)

Separable case. If the question is about separable compact Hausdorff spaces, then the answer is yes. It is enough to assume the weaker condition that $X$ is a compact Hausdorff space that is ccc, which means that every disjoint collection of non-empty open sets is at most countable. (Every separable space is in general a ccc space, as is easily verified but not vice-versa.)

Pick $x,y\in X$ with $x\not=y$, where $X$ is a separable compact Hausdorff space that is ccc. Then $X$ is normal and hence there is a continuous $h:X\to[-2,2]$ with $h(x)=2$, $h(y)=-2$. Using $h$ define $g:X\to[-1,1]$ by $g(z)=-1$ if $h(z)\le-1$, $g(z)=1$ if $h(z)\ge1$, and $g(z)=h(z)$ if $h(z)\in(-1,1)$. It is easily seen that $g$ is continuous with $g(x)=1$, $g(y)=-1$. Let $U=h^{-1}([-2,-1))$ and $V=h^{-1}((1,2])$. Then $V$ and $U$ are open with $x\in V$, $y\in U$, $g(V)=1$, $g(U)=-1$.

There must be $s\in(-1,1)$ such that $g^{-1}(s)$ has empty interior (for otherwise the collection $\{{\mathrm{Int}}\, g^{-1}(t):t\in(-1,1)\}$ would be an uncountable collection of pairwise disjoint non-empty open sets, contradicting that $X$ is ccc.) (We do not rule out the possibility that $g^{-1}(s)$ itself is empty, but that does not change the rest of our argument.)

Fix $s\in(-1,1)$ such that $g^{-1}(s)$ has empty interior. Let $\gamma:[-1,1]\to[-1,1]$ be a monotonically increasing (piecewise linear and) continuous function that fixes the endpoints (i.e. $\gamma(-1)=-1$ and $\gamma(1)=1$), and $\gamma(s)=0$. Let $f=(\gamma\circ g) : X\to [-1,1]$. Then $f(x)=1$, $f(y)=-1$, $f(V)=1$, $f(U)=-1$, and $f^{-1}(0)=g^{-1}(s)$ has empty interior.

Non-separable case. If the question is about compact spaces that are not necessarily separable, then the answer is no (as felt by the OP, and as suggested in one of my comments above). (As a clarification prompted by the comments to my answer, in this case the required $V,U$ and $f$ do not, in general, exist, although they may sometimes exist, even for non-separable spaces.)

Let $H^*$ be the Stone-Cech remainder of the half-line $H=[0,\infty)$. Then $H^*$ is compact and connected, and has the property that every non-empty $G_\delta$ set has non-empty interior. See this answer by Alessandro Vignati and Adam Przeździecki who cleared my confusion about it (see also the answer for the LOTS case by Eric Wofsey and answer by Joseph Van Name about almost $P$-spaces, and perhaps more comments or answers coming there).

We now show that the answer is no whenever $X$ is any compact, connected, Hausdorff space (with at least two points) in which every non-empty $G_\delta$ set has non-empty interior. Take any two different points $x,y\in X$ and any continuous function $f:X\to(-\infty,\infty)$, $f(x)=1$, $f(y)<0$. Since $f(X)$ is connected, it follows that $0\in f(X)$, that is $f^{-1}(0)$ is not empty. Also, $f^{-1}(0)=\bigcap_{n\ge1}\, f^{-1}((\frac{-1}n,\frac1n))$ is a $G_\delta$ set. Hence $f^{-1}(0)$ has non-empty interior. Since the points $x,y$ and the continuous function $f$ were arbitrary, this answers the question negatively. (To be more specific, when $X=H^*$ for example and $x,y\in X$ are any two different points, then $U,V$ and $f$ as asked by the OP, do not exist. We could not find $f$ such that $f^{-1}(0)$ has empty interior, even if we disregard the conditions about $U,V$.)

Edit. Prompted by the comments, is seems my answer needs clarification (although the above is correct). Namely, the answer is in general no, that is, if $x,y$ are two points in a compact Hausdorff space $X$ we cannot conclude the existence of $V,U$ and $f$ as asked by the OP. If $X$ is in addition separable (or more generally, if $X$ is ccc), then yes, we could find such $V,U$ and $f$.

It so happens that for some $X$ that are not separable, we could find such $V,U$ and $f$. For example let $X=[0,\omega_1]$ be the space of all countable ordinals together with the first uncountable ordinal, with the order topology. Then $X$ is compact and not separable. If $x,y\in X$ with $x<y$ then $V=[0,x]$ and $U=(x,\omega_1]=[x+1,\omega_1]$ are disjoint closed-and-open neighborhoods of $x$ and $y$ respectively, with $X=V\cup U$. If we define $f(v)=1$ for every $v\in V$, and $f(u)=-1$ for every $u\in U$, then $f$ is continuous with $f^{-1}(\{0\})$ being empty, in particular having empty interior. So all conditions asked by the OP are satisfied for this particular choice of $X=[0,\omega_1]$. But, unless the answer is yes for every choice of $X$ and $x,y$, then the answer is, in general, no. The answer is no for $H^*$ (as discussed above), hence the answer is no.