The lub-dub sound is produced by the closing and opening of the heart valves during the cardiac cycle. Here's what happens:

Shortly after the lub , the lower chambers contract to push blood out of the heart to the lungs and the rest of the body. Once the blood is pushed out, the "exit doors" must slam shut to prevent blood from leaking back into the heart.

The lub is the sound of two specific valves slamming shut: