An electromagnet is used in the earpiece of a telephone. The figure shows the simple structure of a telephone earpiece.
When you speak to a friend through the telephone, your sound will be converted into electric current by the mouthpiece of the telephone. The current produced is a varying current and the frequency of the current will be the same as the frequency of your sound. The current will be sent to the earpiece of the telephone of your friend.
When the current passes through the solenoid, the iron core is magnetised. The strength of the magnetic field changes according to the varying current. When the current is high, the magnetic field will become stronger and when the current is low, the magnetic field become weaker.
The soft-iron diaphragm is pulled by the electromagnet and vibrates at the frequency of the varying current. The air around the diaphragm is stretched and compressed and produces sound wave. The frequency of the sound produced in the telephone earpiece will be the same as your sound.