There are a few reasons why small speakers have trouble creating bass.
1. Bass is directly proportional to the amount of air the speaker can move. So you want a large cone that can move a large distance. That's hard to package in small box.
2. A conventional cone loudspeaker has actually two sound sources: the front of the cone creates positive pressure while at the same time the rear of the cone creates negative pressure. These two pressures need to be separated otherwise they cancel each other. That's why you put a bass speaker in a box. The box contains the pressure from the back of the cone. That also means that the speaker needs to compress the air in the box and the air will push back. 309
The smaller the air volume in the box, the harder it will push back and the more force is required to compress it. Interestingly enough, a small speaker spends a large part of it's energy to compress air in the box, not radiating sound to the outside world (which takes a lot less energy).
3. Loudspeakers create a spherical wave where the sound pressure falls proportional to the distance. They are very loud when you are very close, but the sound pressure drops VERY quickly as you move away.
Headphones and ear phones have the advantage that they are very close to the ear, so you are operating still in the "VERY loud" part of the distance dependency.
Sitting on the head reverses the "box" problem. You only need to pressurize a very small volume while you can vent the back pressure to the outside world which is huger by comparison. Since the volume is so small, there is only very little movement required. One way to think about this: room speaker needs to pressurize the entire room, an ear phone only needs to pressurize the tiny little volume inside the air canal.
The bass response for both headphones and ear phones is very sensitive to the air seal between the ear cup or ear bud to the body. Any leakage will result in some cancellation of the front and back pressure. There are ways around this with so-called "open headphone", but that's probably to deep for this answer. 309