If you pull the trigger on this, you're ruining someone's day, somewhere and sometime.
Gunnery Chief, from Mass Effect 2
Gunny makes a really good point, there. (Follow link for full quote.) For projectile-based weapons in space, a "miss" is really a "hit" - just not on your intended target, and not necessarily in the very near future. (In fact, maybe not even within your lifetime.) Energy-based weapons may dissipate and fizzle, but a projectile left unattended could have substantial consequences for "innocent bystanders".
Voyager sort-of touches on this, though not particularly addressing weapons, in the episode Friendship One. However, I'd like to know if there's an episode that specifically calls out how Starfleet takes responsibility (or doesn't) for its stray projectile weapons.
In a number of cases throughout Star Trek history, we're shown that it is possible to prematurely detonate missiles or photon torpedoes on-demand. Is it ever stated or shown that there is a safety system to detonate them if they miss an intended target? Is a failure of such system ever highlighted?
NOTE: My personal viewing history currently includes all of TNG, DS9, and VOY, and part of season 1 in ENT. Please use spoiler Markdown appropriately for this.