So, two things happen. First, they disperse. Because as they go out, the waves expand, so that they’re covering a larger and larger area. Because of conservation of energy, you can’t have it still be the same intensity if it covers a larger area, and so the sound will get progressively weaker as it travels, like the ripples in the pond. There is a point where they’re too low for us to hear but they’re still detectable for a while. However, they don’t travel forever.
So, that brings up the next point. The first point is from the first law of thermodynamics (conservation of energy), the second is from the second: entropy always increases. What that means in this case is that you have energy in one form: sound. Over time, that energy will, for lack of a better term, degrade, and turn into other more chaotic forms of energy. Mostly heat. Sound is, at a basic level, the result of atoms bumping into each other, that’s why you can’t hear anything in space. As this bumping is going on, they may also heat up a little. Going back to the first law, if they heat up, that energy must come from somewhere, and so it comes from the sound’s energy. And so over time the area the sound passes through heats up just a tiny, tiny bit, and the sound gets weaker and weaker, until everything is converted to heat (and a few other energy types, but mostly heat) and there’s no sound left.
As to your question, @Skaggfacemutt, it’s very similar, though the difference being photons don’t travel through a medium like sound, and so they can travel in space. But photons can still be scattered and absorbed like sound, and so if it’s in an area with lots of atoms around, say inside a house, those photons will get trapped and eventually turned into heat. If you shined a flashlight into space and the photons made it out, they would indeed just keep in going, since there’s very little there to absorb or scatter them. But you’d have the same ripple problem in that they’d just keep spreading out and getting weaker, and by the time it reached anything else at all you’d be down to probably just a photon or two, which is nigh undetectable unless you’ve got some really impressive equipment.