Does a headwind affect the climb gradient?
The gradient of climb is the ratio of the increase of altitude to horizontal distance through the air, not over the ground. 
The definition used by the UK CAA in CAP 698 is:


  Climb Gradient  
  
  The ratio, in the same units of measurement, expressed
  as a percentage, as obtained from the formula:
  - $$\text{Gradient} = \frac{\text{Change in Height}}{\text{Horizontal Distance}} \times 100 \% $$


If you have a headwind or a tailwind it makes no difference to your climb gradient because your airplane is moving relative to the air mass. 

Climb gradient is not the same as rate of climb, although they are related. Rate of climb is altitude over a period of time, gradient is climb over distance travelled. There is another question which covers the difference in more detail.