Oxide heterostructures are of great interest for both fundamental and applicative reasons. In particular, the two-dimensional electron gas at the LaAlO_{3}/SrTiO_{3} or LaTiO_{3}/SrTiO_{3} interfaces displays many different properties and functionalities. However, there are clear experimental indications that the interface electronic state is strongly inhomogeneous and therefore it is crucial to investigate possible intrinsic mechanisms underlying this inhomogeneity. Here, the electrostatic potential confining the electron gas at the interface is calculated self-consistently, finding that such confinement may induce phase separation, to avoid a thermodynamically unstable state with a negative compressibility. This provides a robust mechanism for the inhomogeneous character of these interfaces.