A typical speaker contains two magnets and a cone made of paper or plastic (see the following figure). The black material you see in the mini-speaker shown is the paper cone. One of the speaker's magnets is a permanent magnet (meaning that it is always magnetized) and the other is an electromagnet.
An electromagnet is just a coil of wire wrapped around a hunk of iron. If no current passes through the coil of wire, the electromagnet is not magnetized. When current passes through the coil of wire, the electromagnet becomes magnetized and gets pulled and then pushed away from the permanent magnet. The cone is attached to the electromagnet, so when the electromagnet moves, the cone vibrates, creating sound (which is just moving air).
If you look closely at the back of the speaker, right, you might be able to see that one side of each lead wire is sticking through the back of the black cone. Those wires are connected to the coil inside the speaker. By connecting the other side of the lead wires to your circuit, you control the flow of current through the coil. Depending on what your circuit is doing, current may or may not flow through the coil, and you may or may not hear sound coming from the speaker.