The water content of magma oceans is widely accepted as a key factor that determines whether a terrestrial planet is habitable. Water ocean mass is determined as a result not only of water delivery and loss, but also of water partitioning among several reservoirs. Here we review our current understanding of water partitioning among the atmosphere, magma ocean, and solid mantle of accreting planetary embryos and protoplanets just after giant collisions. Magma oceans are readily formed in planetary embryos and protoplanets in their accretion phase. Significant amounts of water are partitioned into magma oceans, provided the planetary building blocks are water-rich enough. Particularly important but still quite uncertain issues are how much water the planetary building blocks contain initially and how water goes out of the solidifying mantle and is finally degassed to the atmosphere. Constraints from both solar-system explorations and exoplanet observations and also from laboratory experiments are needed to resolve these issues.