It made no sense for McCoy to be helping with the torpedo realistically speaking (if you consider Trek "realistic"), but it made for some good Bones one-liners which outweighed the "not making sense" aspect for me.
Moments like...
Spock: "Doctor, would you care to assist me in performing surgery on a photon torpedo?"Based on this thread and others, I'm sure there are plenty of folks who hate the humor in those scenes. But I loved it.
McCoy: "Fascinating!"
"We have a heartbeat."
"I'd give real money if he'd shutup."
Those are some of my favorite lines from the film, so you are not alone in that fact

Another possibility is that they were in the middle of a tense, uneven battle, which means that weapon's officers might be at a premium in terms of combat processes. McCoy was the closest with free hands.
Regardless, it does nothing to diminish my enjoyment of the scene.