So you'd think, because you're used to the idea of nukes being set off in the atmosphere. However, this is the vaccuum of space. There's no atmosphere to heat up and create a shockwave in. The only form of energy transfer you have is the tiny amount of bomb material that is ejected from the explosion, and the gamma radiation from the blast. Neither will impart any significant momentum on the asteroid.
The only chance you have to affect the course of the asteroid is if the blast vaporizes a large amount of material off the surface of the asteroid, and this material is ejected at high enough velocity to nudge the rest of the asteroid in the other direction. But as nobody has tried to do this, we have no idea if it would be enough or not. That's why the idea is a bad one - we have no idea if setting off nukes next to an asteroid would do anything useful at all.
Of course, there's a surefire way to find out for sure.