We consider an asymmetric 0-π Josephson junction consisting of 0 and π regions of different lengths L0 and Lπ. As predicted earlier this system can be described by an effective sine-Gordon equation for the spatially averaged phase ψ so that the effective current-phase relation of this system includes a negative second harmonic sin (2ψ). If its amplitude is large enough, the ground state of the junction is doubly degenerate ψ=±φ, where φ depends on the amplitudes of the first and second harmonics. We study the behavior of such a junction in an applied magnetic field H and demonstrate that H induces an additional term Hcos ψ in the effective current-phase relation. This results in a nontrivial ground state tunable by magnetic field. The dependence of the critical current on H allows for revealing the ground state experimentally.