Ok something has always bothered me about that scenario and perhaps someone could explain it to me. What would actually deflect or damage the comet/asteroid? It was my impression that the destructive force of a nuclear blast (that which destroys buildings and such at a distance and presumably this comet) is the shock wave generated. Wouldn't this require air? So how would it impact a comet or asteroid is space? I know there are other forces generated such as heat but I don't see how they would necessarily work to change the course of a comet.
In a word - photons. The
damage caused by nuclear weapons is largely from the shockwave, but that shockwave doesn't just appear out of nowhere, it is caused by the energy released in the nuclear reaction. Even if there is no air, that energy is still there. While an individual photon may not have much energy or momentum, if you have a lot of them it all adds up. Even just the radiation from the Sun is enough to have an effect on the orbit and rotation of asteroids, and in principle could power spacecraft using solar sails. The radiation from a nuclear explosion nearby would be far more intense. In fact, a nuclear explosion in a vacuum could be far more effective than one in an atmosphere. Shockwaves tend to be very lossy phenomena, so a lot of the energy from the explosion is wasted that wouldn't be in a vacuum.
However, shockwaves can have some advantages. In space, a minimum of 50% of the radiation will be emitted away from the target and is wasted. In air, and near the ground, some of that energy can still contribute due to absorption, reflection and so on. Overall though, while a nuclear explosion in space may not do as much damage, more energy and momentum will be transmitted to the target.
Burying the bomb inside the target would ensure that all the energy was tramsitted to it, but would waste most of that in damaging it rather than actually moving it. However, it is thought that many asteroids and comets are actually just loose collections of rubble, without enough gravity to compact them into a solid body. In this case, having a bomb at the centre could push the rubble in different directions, so some might miss altogether and the bits that do still hit would arrive more spread out in time resulting, hopefully, in an intense meteor shower rather than a single massive impact.
Edit: However, there are still three problems, two already mentioned by Seismosaur. Firstly, you need to get there very early. Last minute heroics work in Holywood, but not in real life. You're almost certainly looking at at least a couple of years if you want any chance of actually deflecting anything. Secondly, we actually know very little about asteroids and comets, so it is very hard to know what the effects of any actions would actually be. A bomb might push it as planned, it might blow it apart and it might have almost no effect. Until we try it, we just don't know. Thirdly, we don't actually have any way of getting nuclear weapons to the right place. This is probably the least of the problems from a technical point of view since we know we can already send things to asteroids, it's just a matter of doing so with warheads. Politically, however, the idea of sending nuclear weapons into space is a rather tricky matter.