We present a thorough analysis of the electron density distribution (shape) of two electrons, confined in the three-dimensional harmonic oscillator potential, as a function of the perpendicular magnetic field.Explicit algebraic expressions are derived in terms of the systems parameters and the magnetic field strength to trace the shape transformations in the ground and low-lying excited states. We found that the interplay of the classical and quantum properties lead to a quantum shape transition from a lateral to a vertical localization of electrons in low-lying excited states at relatively strong Coulomb interaction with alteration of the magnetic field. In contrast, in that regime in the ground states the electrons form always a ring type distribution in the lateral plane. The analytical results demonstrate a good agreement with quantum numerical results near the transition point and at high magnetic field.