In space, the only medium the weapon has to work against is the asteroid itself, so for a thermonuclear bomb to be of any use against an asteroid, it would need to be inserted into it.
Nukes wouldn't really deflect an asteroid because the release of energy is too sudden; a more effective solution is to detect an Earth-bound object early, and then attach thrusters to it, using long-term forces to manipulate its trajectory. Breaking off any parts, before or after it passes Earth, would be too risky as it would be almost impossible to determine what path they would take after detonation.