In this work we demonstrate theoretically how to use external laser field to control the population inversion of a single quantum dot exciton qubit in a nanocavity. We consider the Jaynes-Cummings model to describe the system, and the incoherent losses were take into account by using Lindblad operators. We have demonstrated how to prepare the initial state in a superposition of the exciton in the ground state and the cavity in a coherent state. The effects of exciton-cavity detuning, the laser-cavity detunings, the pulse area and losses over the qubit dynamics are analyzed. We also show how to use a continuous laser pumping in resonance with the cavity mode to sustain a coherent state inside the cavity, providing some protection to the qubit against cavity loss.