The ocarina is a wind instrument which is quite common in Hyrule, though personally it looks more like the flute from A Link to the Past for the SNES. Obviously, this instrument is in the title of the game, so you can expect that much of Link's adventure revolves around listening and playing music.
There are two different ocarinas Link can play during his adventure. There are thirteen tunes which Link can learn, twelve appearing on the Quest Status screen, though rumours number this as high as fifteen.
Whenever you come across someone or something who mentions anything about music, you should hold out your ocarina and play a song; exactly which song varies from circumstance to circumstance. You won't be able to progress unless you know which songs to play and where to play them.
When you hold an ocarina in your hand, press the buttons which make up the first few (five or more) notes of the song you want to play. Link will then play the song through, and whatever effects it has will take place. Note that if you know the notes of a song, but haven't actually learned it in the game, you still won't be able to play the song.
INSTRUMENTS
Fairy Ocarina: When you first leave Kokiri Forest after getting the Kokiri Emerald, Saria will be waiting. As a momento, she will give you this instrument. It's the same ocarina just about every other Hyrulian citizen can find. Note that once you gain the Ocarina of Time, this instrument will be discarded.
Ocarina of Time: This mysterious, magical instrument is a hidden treasure of Hyrule's Royal Family. You can only gain it after getting all three Spiritual Stones: head for Hyrule Town and Zelda will be evacuated on horseback, when at the last moment she'll toss this at you and it'll land in the moat. After Ganondorf rides off, you'll be able to obtain it.
SONGS
Zelda's Lullaby: After you first meet Princess Zelda, Impa will guide you out of Hyrule Town. As she does so, she will teach you this song. Also known as the Song of the Royal Family or something similar, this is probably the most commonly-used song in the entire game; play it wherever there's the symbol of the Triforce, proof of Royal connection is required, or to repair broken signs.
Epona's Song: Send Talon back to Lon Lon Ranch and Malon will be in the corral with a fole named Epona during the day. Keep talking to Malon and she will offer to teach you this song. Though Malon refers to it as her mother's song, the game will call it Epona's Song. It serves two main purposes; to summon Epona and to get a free bottle of Milk from cattle.
Saria's Song: This is one of the trademark tunes of the Kokiri. You'll learn it from Saria who, meloncholy after Link leaves the Lost Woods, is now in the Sacred Forest Medow. Simply approach her and you'll learn this song. You need this song to gain the Goron Bracelet, but it can also be used to receive advice from either Saria or Navi.
Sun's Song: One of two songs you may or may not learn during the game is the Sun's Song, which can freeze ReDeads and Gibdoses in their tracks. Its more frequent purpose is to turn night into day, and vice-versa. Either Young or Adult Link can learn this song.
At the back of Kakariko Village's Graveyard is the Royal Family's Tomb, watched over by the two Composer Brothers. Play Zelda's Lullaby on the Royal Family's Emblem to gain access to this area. Kill all the bats in the tomb and you'll find yourself in a room full of ReDeads and toxic pits; work you way to the back of here and you'll come to an enscribed poem, which includes learning this song.
Song of Time: When you gain the Ocarina of Time, you will receive a telepathic message from Zelda. Part of this message involves learning the song which will open the Door of Time. Also, if Navi turns green over a crevace or you come to a block with the Door of Time's symbol, use the Song of Time to teleport that block.
Song of Storms: As Adult Link, enter Kakariko Village's Windmill. Inside is an organ-grinding music maker who is rather peeved off about a young boy with an ocarina. Show your own ocarina and he'll teach you this song, which summons a brief storm. Use this song to reveal some hidden areas, and to gain access to the Bottom of the Well. It can also flush fairies out of hiding from certain areas.
Minuet of Forest: When Adult Link reaches the back of the Sacred Forest Meadow for the first time, Sheik will appear and teach you this song, which enables you to warp back to the medow at any time.
Bolero of Fire: One of my personal favourites, Sheik teaches you this song after you cross the broken bridge in the Death Mountain Crater. It allows you to warp to the Crater at any time.
Serenade of Water: After gaining the Iron Boots from the Ice Cavern, Sheik appears and informs you of the fate of the Zoras. He also teaches you the song which enables you to warp to the main island at Lake Hylia.
Nocturne of Shadow: Enter Kakariko Village from Hyrule Field after getting the Forest, Fire and Water Medallions. As the Phantom Shadow Beast is released, Sheik asks you to help Impa at the Shadow Temple. This song enables Link to warp to the Graveyard, on a ledge which cannot be accessed any other way.
Requiem of Spirit: Traverse the Haunted Wasteland and enter the Spirit Temple. Since Link cannot continue, exit and Sheik will be waiting. The masked Sheikah will tell you of how it will be necessary for Young Link to enter the Spirit Temple; he then teaches you the song which warps Link to the Desert Colossus.
Prelude of Light: This song is the one which warps you directly to the Temple of Time. You may only learn it after you recover the Forest Medallion; it is only then that Sheik teaches you the song and moves away from the Pedastel of Time.
Scarecrow's Song: The second song you may or may not learn during the game. Since it is Link who decides which notes make up this song, it does not appear on the Quest Status screen. If you play this song at the right spot, the scarecrow Pierre appears and can be used as a Hookshot anchor.
Getting this song requires a bit of travel: first, Young Link must play an eight-note tune to Bonooru at Lake Hylia. This song cannot be one of the existing songs. Now Adult Link must play the exact same tune to Bonooru for the song to be permanently imprinted. You can change the Scarecrow's Song at any time by playing the song as Young Link, then repeating it as Adult Link.
Aside from using the A and C buttons to play, you can use the L, R and Z buttons and the Control Stick to create flats, sharps and other such variations of the five notes.