I'm stuck on that too funnily enough, I've beaten it before on the GBA nes classics version, you just need to persevere, hitting it's heads, if it helps i'd reccomend stocking up on heart containers and getting the red potion/water of life
you need to get a letter from an old man in the north east area of the map, and give it to the woman in a cave that doesn't have text, then you can purchase it, also you may want to save up 250 rupees for the blue ring, and the level 2 sword
You may have already beaten it but in case you have not, what I do is stand is stand next to it from my left or right and slash away. He tends to not hot you in that position. Hope this helps
He can actually be a rather easy boss. All you have to do is slash at his heads. With the whit sword, it takes 4 hits per head. Avoid the fireballs and floating heads, their fireballs can't be deflected with the Magic Shield. And if you think this is hard, prepare yourself; later in the game, there will be a Gleeok with 3 heads, and one with 4 heads. Thankfully, you should have the Magic Sword by then, magic this fight a breeze.