The movie should be at least a decade-old, and perhaps even a TV-movie. In the end of the movie, the heroes launch the weapon in their ship, probably against their enemy ship, but unknowingly, their own ship direction was changed in the middle of the movie, so now it's launched against Earth.
This could be a blurry remembering of the Outer Limits episode, The Light Brigade.
Relevant quotes from the Wikipedia article for the episode:
Unfortunately the aliens ambush the ship, and use their unique methods to trick the survivors of the Light Brigade into failing their mission.
....bomb is released over what the crew believe to be the alien homeworld. It is in fact Earth,....