We have studied the role of defects on the magnetic properties of carbon materials using first-principles density functional methods. We show that, while the total magnetization decreases both for diamond and graphite with increase in vacancy density, the magnetization decreases more rapidly for graphitic structures. The presence of nitrogen nearby a vacancy is shown to produce larger macroscopic magnetic signals as compared to a standalone carbon vacancy. The results indicate the possibility of tuning magnetization in carbon by controlled defect generation and doping.