Electronic and magnetic properties of cobalt doped ZnO, with and without O vacancies, were investigated using ab-initio calculations. Calculation shows that Co-doped ZnO can achieve different magnetic stable configurations as dependent on oxygen vacancy (VO) concentrations. The electronic structure illustrates that when there are VO in the structure, the ferromagnetic phase is the most stable configuration with the highest Curie temperature. Also, DOS and pDOS show that the total magnetic moment mainly consists of interaction between Co, VO, and O atoms, where the largest contributions come from the d-Co and p-O orbitals. The magnetization per Co atom shows a strong correlation with the formation energy decrease, which increases with the impurity-vacancy distance. Finally, the presence of VO results in a lower average magnetic moment per unit cell, which was also observed in the spatial spin-density distribution. These results indicate that VO in Co-doped ZnO could be the crucial key to achieve stable ferromagnetism in this diluted magnetic semiconductor with potential applications in spintronic devices.