You can use a nuke in multiple ways.
As a deflector (launched years or decades from impact), you can nudge the impactor out of its present orbit by gently ablating one side from a distance; You can do this iteratively until the impactor's orbit changes enough to miss Earth.
Decades is sufficient for some of the continuous-thrust alternatives, though, depending on scale.
As a point defence weapon (launched weeks or months from impact), you can send the nuke in as close as possible and detonate in order to break up the body. Yes, this would cause lots of smaller impactors, but over some size ranges it's preferable because ablation is insufficient. If 99% of the smaller impactors miss Earth, we win... in some cases.
Just breaking up a large impactor (at the very last minute, launched minutes or hours before impact) doesn't help so much if everything still hits Earth, because a planet-killer turns into hundreds of city-killers randomly spread out.
On the other hand, a small impactor could be dramatically affected by a nuke, with plausible amounts of vaporization going on. There's quite a lot of risk surface in small impactors, and they would be hard to spot until very close.
---
Bong Wie is working through a NIAC grant on the problem:
http://www.spacesafetymagazine.com/space-hazards/asteroid-hi...
One interim observation: a nuke which detaches from a small cratering round which hits first, digging a hole for the nuke to fit in, would multiply its effectiveness severalfold.
It's a very different problem in each different size class of impactor (as well as orbital classes). 10m, 100m, 1000m, 10000m are all of concern in unique ways; each order of magnitude increase in diameter raises mass by three orders of magnitude.