Why does my ocarina sound out of tune?
The most common reason an ocarina will sound out of tune is limited player skill. An ocarina's pitch changes greatly with blowing pressure. Consequently, blowing too hard or soft will push the pitch sharp or flat.
Each note will only sound in tune at one pressure; the lowest notes need the least and highest the most. How this pressure changes from note to note is called the breath curve.
Breath curves vary enormously from maker to maker, so there is no single definition of what an 'in tune' ocarina is. Some have a regular increase from note to note while others increase exponentially. Some require the slightest pressure whereas others need a lot.
To play in tune, you have to change your breath pressure to match your instrument's unique curve. This skill can be learned using a chromatic tuner, and by playing with accompaniment. This is covered in detail on the page 'Playing the ocarina in tune'.
Also note that the absolute pitch of an ocarina is temperature sensitive. If you are playing in an environment notably colder than the ocarina was tuned in, it may be impossible to play in concert pitch, as it will squeak on the high notes. The ocarina will still play in tune with itself at a flatter pitch.
Ocarinas have variable quality
A lot of what is sold under the name 'ocarina' in mainstream outlets are of very poor quality. If the ocarina was very cheap, there is a good chance it is untuned or badly tuned. If this is the case, you are best off just getting a better instrument. See 'Identifying playable ocarinas'.