When can we separate an open set from its complement by a continuous function? Given a topological space $X$, and an open set $U \subsetneq X$. When can we say that, given $n \in \mathbb N$ there exists a continuous real valued function $f \rightarrow \mathbb R$, such that, $f(U) \subset (-\frac{1}{n},\frac{1}{n})$ and $f(U^c)  \geq\left|\frac{1}{n}\right|$.
Thank you!
 A: The answer to the original question with $f(U^c)\subset {\mathbb R}\setminus [-1/n, 1/n]$: If and only if $U$ is not only open but is also closed.
Answer to the modified question: Such function always exists, provided that $X$ is metrizable. (Hint: Use a suitable modification of the distance function to $U^c$ in order to define the function $f$.)  If $X$ is not assumed to be metrizable, the answer is, in general, negative.  
A: A space where every closed set is  the zero set of a continuous function (which is basically equivalent with what you ask) is called perfectly normal. See 
Zero set and Perfectly normal space in wikipedia.
In general, a set that is a zero-set of a function in an arbitrary space is not characterizable.
A: Note that your question is equivalent to the following

Given an open subset $U$ of a topological space $X$, when can we say that there is a continuous real-valued function $f$ on $X$ such that $f(x) > 0$ for all $x \in U$ and $f(x) = 0$ for all $x \notin U$.

Such a set $U$ is called a co-zero set (or, in Engelking, a functionally open set); their complements are zero sets (or, in Engelking, functionally closed).  It is easy to show that zero sets  are G$_\delta$ (since $f^{-1} [ \{ 0 \} ] = \bigcap_{n} f^{-1} [\;(-1/n , 1/n )\;]$).  It follows that co-zero sets are F$_\sigma$.  In normal spaces, the co-zero sets are exactly the open F$_\sigma$-sets.  (To circle back to other questions that you have asked, this means that in perfectly normal spaces, the co-zero sets are exactly the open sets.)
However in non-normal spaces, there may be closed G$_\delta$-sets which are not zero sets.  For example, in the Niemtyzki (or Moore) plane, the set $F = \{ \langle x , 0 \rangle : x \in \mathbb{Q} \}$ is a closed G$_\delta$ set which is not a zero-set.
