We model the quantum confined Stark effect in AlN/GaN/AlN heterostructures grown on top of [0001]-oriented GaN nanowires. The pyro- and piezoelectric field are computed in a self-consistent approach, making no assumption about the pinning of the Fermi level, but including an explicit distribution of surface states which can act as a source or trap of carriers. We show that the pyro- and piezoelectric field bends the conduction and valence bands of GaN and AlN and transfers charges from the top surface of the nanowire to an electron gas below the heterostructure. As a consequence, the Fermi level is likely pinned near the valence band of AlN at the top surface. The electron gas and surface charges screen the electric field, thereby reducing the Stark effect. The efficient strain relaxation further weakens the piezoelectric polarization. We compute the electronic properties of the heterostructures with a sp3d5s* tight-binding model, and compare the theoretical predictions with the available experimental data.