In The Legend of Zelda: Ocarina of Time, there are three optional Ocarina songs essential for completing the whole game. These are Epona’s Song, Sun’s Song, and the Scarecrow Song, which are used for various purposes from calling Epona to altering time and accessing places that cannot be reached in any other way. Here’s how to learn all three.
How to Learn Epona’s Song

Location: Lon Lon Ranch
Requirement: Child Link
Go to Lon Lon Ranch as Young Link and go to the area where the horses are. Speak to Malon, who will show you Epona and will ask you to go with her.

Approach Malon and take out your Ocarina. She will play some notes, which you must repeat in order to learn Epona’s song. After you learn it, it will be registered in your songbook.
What can you do with Epona’s song: After you become Adult Link, you will be able to play Epona’s song at Lon Lon Ranch and call for Epona. Speak to the man at the ranch and pay to be able to ride some horses. Challenge him to race with you and win a second time to keep Epona. Then you will be able to jump over the fence and exit the ranch.
How to Learn Sun’s Song

Location: Royal Family’s Tomb, Kakariko Village Graveyard
Requirement: Child Link

Travel to the graveyard in Kakariko Village and go to the Royal Family’s Tomb. Use Zelda’s Lullaby in front of it to see cutscenes of lightning striking the tomb.
You are supposed to enter the tomb and destroy four bats in the first room. There are two bats right in front of you and the other two can be seen on two separate pillars. You can defeat them using your Slingshot.

Next, utilize the stairs and go into the next room, where several ReDeads will be waiting for you. Do not let them see you and if one grabs you, just button mash with the control stick. Go to the back of the room and interact with the tablet. Navi will show you a sequence of musical notes. Repeat them with your Ocarina to learn Sun’s Song.
What Sun’s Song Does: It helps you to change the time of the day. Also, it can freeze ReDeads by playing it near them.
How to Learn the Scarecrow Song

Location: Lake Hylia
Requirement: Child Link and Adult Link
Go to Lake Hylia as a young Link and encounter the scarecrow located at the bottom left corner of the area. After talking to him, take out the Ocarina and create a song by playing a number of notes in sequence.

Make sure to take a screenshot since the song is not saved at that point. Later, when you come back as adult Link, visit the scarecrow again and play the same tune. The scarecrow will recognize the music and you will be able to learn it.
Important: If you lose your song, you must go back in time through the Temple of Time returning the Master Sword to its pedestal first. As Child Link, compose a new song, then draw the Master Sword again to return as an adult and use it with the Scarecrow.
What the Scarecrow Song Does: The purpose of this song is to summon the second scarecrow called Pierre in certain locations. Look for straw that is moving in the wind and play this melody to make him show up. After this, you can use your Hookshot to get to him. For instance, on the Forest Temple, Pierre gives you a chance to get to the Gold Skulltula.
These are all three optional Ocarina songs: Epona’s Song, Sun’s Song, and the Scarecrow Song. Learning them can make travelling around Hyrule and exploring different areas much easier.

