If it was a spacewalk then everything would have to be up in a rigging, including the two actors and the torpedo. Unless you used a transporter (potentially dangerous with a volatile new torpedo), you'd have to build a new external airlock or torpedo bay set. And you might want some spectacular vista in the background instead of just a plain, boring field of stars, so there's the cost of CGI. So, unless the ground location shoot was on some far off exotic island, I could see it being cheaper to just do it that way.