The principle of operation behind an earphone is so simple; vibrating magnet in a varying magnetic field will produce sound. Given this understanding, you can start building your own earphone using materials around your home (except for button magnet and copper wire, I guess).
Before I move further, here is the photo of my finished homemade earphone:
You may not understand the photo, so I included here my plans of making it:
I used neodymium button magnet for this project and 36 SWG copper wire. Neodymium magnet is strongest man-made magnet, it will response to small magnetic field generated within the copper coil in the earphone. So in other words, by using this magnet, it makes my earphone more sensitive.
The principle of operation is as explained in the above photo.
The quality of sound is akin to that of real earphone, but not to that of speaker. The bass and low frequency sound are very clear, perhaps because I used rubber piece cut from balloons (so it is more elastic as a diaphragm and vibrate easily at lower frequency compared to plastic diaphragm which is quite hard to vibrate at that region of frequency)
I really wanted to put a video here to show that it really works, but my Iphone camera cannot record low strength sound (from earphone) very well. Anyway, it really works and if you dont have earphone, you can make one by just using a magnet, copper wire and some stuffs laying around your house.
Good luck if you wanna try it.
Update (8 July 2012): The earphone can actually functions as a loudspeaker, but with significant audio distortion compared to commercial 8 ohm loudspeaker. In the following video I connected the homemade earphone to the LM386 audio amplifier which amplifies the audio input from my laptop (connected using 3.5mm jack audio cable, the yellow pins with black cable in the video). I think this homemade earphone is just best serving as earphone since it distorts audio signal at higher volume.