The definition of $U'$ doesn't depend on the Topology on $Y$.
Given any map $f:X\rightarrow Y$, we can consider the equivalence relation $x'\sim x$, iff $f(x)=f(x')$ on $X$ and factor the map $f$ as $X\rightarrow X/\sim \quad \rightarrow Y$. Call the first $f'$. Note that,the second map is injective. Hence we get the same set $U'$ for any set $U$, if we replace $f$ by $f'$.

So we might assume without restriction, that $f:X\rightarrow X/\sim $ is a quotient map. Then the upper statement is equivalent to saying, that $f$ is closed.

Suppose $f$ is closed. Then one gets for the complements $U'^c=f^{-1}(f(U^c))$. And hence $U'^c$ must be closed.
There is the closed map lemma, which shows, that under the nice conditions mentioned in the comments above properness is also sufficient.

Now suppose $f:X\rightarrow X/\sim$ is not closed and a quotient map. Then there is a closed set $A\subset X$, such that its image is not closed. By definition of the quotient topology, a subset of $X/\sim$ is closed, if and only if its preimage is closed. So $f^{-1}(f(A))$ is not closed and hence $U=A^c$ gives the desired counterexample.

So we get: A map $f:X\rightarrow Y$ has the property, if and only if the induced map $X\rightarrow X/\sim$ is closed.

`$f^{-1}(\{y\})$`

is not compact? – François G. Dorais♦ Mar 9 '10 at 16:57