Why do you only hear the bass when someone nearby is wearing earphones?

You don't.

You actually hear the high frequency notes from headphones. The bass really doesn't travel at all well, but the attack noise from the drum or bass guitar is what leaks from headphones.

This is why on the tube you hear "tsss tsss tsss tsss" and very little else.

From @leftaroundabout's answer on the post that valerio92 linked:

Normal headphones are basically dipole speakers, and especially for bass frequencies (wavelength much larger than the speakers) this describes their behaviour well. So the amplitide decreases ∝ 1/r4. At higher frequencies, they also have some monopole components which decay more slowly, with the familiar inverse-square. So if you're listening from far away, you'll mostly hear those treble frequencies and little or no bass. OTOH, while wearing the headphones there's little difference since you're in the near field where neither frequency range has decayed substantially at all.


To add to the existing answer, I think there is a nomenclature issue. When you say "bass" people understand "low frequencies" but what you probably mean is "beat". Rapid changes in amplitude, like a beat, carry a lot of high frequencies. You do hear mostly the beat from other peoples' headphones, ans it's annoying.

You can think about the extreme case: the square wave (image from Wikimedia). Although in physical systems the variation is always transient, the closer you are to an instantaneous change in amplitude, the more high frequencies the signal will contain.

enter image description here