The optimal superconductivity (Tc≈30 K) in BaFe2(As1−xPx)2 can be reached when the coupled antiferromagnetic (AF) order (TN) and orthorhombic lattice distortion (Ts) are suppressed to zero temperature with increasing of P concentration or hydrostatic pressure. Here we use transport and neutron scattering to study the c-axis pressure effects on electronic phases in underdoped BaFe2(As0.72P0.28)2, which has TN=Ts≈40 K and Tc≈ 28 K at zero pressure. With increasing c-axis pressure, TN and Ts are slightly enhanced around Pc∼20 MPa. Upon further increasing pressure, AF order is gradually suppressed to zero, while Tc is enhanced to 30 K. Our results reveal the importance of magnetoelastic couplings in BaFe2(As1−xPx)2, suggesting that the c-axis pressure can be used as a tuning parameter to manipulate the electronic phases in iron pnictides.