Firstly, Link must remove the Helmasaur King's mask by hitting it with the Hammer. It is also possible to use Bombs, but the Helmasaur King will most likely have moved away by the time they explode. However, if you obtained the bomb upgrade from the fairy, I suggest you stick with bombs since they shatter his mask far quicker than the hammer. If Link stands right in front of it, he will be safe from its tail, but if it opens his mouth and fires three fireballs at him, stand in-between the lower two and inline with the top one. They will each split into four but it should be safe.
Once its mask is gone, the Helmasaur King will reveal a green spot which Link must hit with Arrows. Its attacks don't really change but it will start to move a bit quicker, making it harder to hit. After about seven hits with arrows on the green spot, the Helmasaur King will be defeated.
Palace of the Four Sword
In the GBA version of A Link to the Past, the Helmasaur King makes an appearance in the additional game, Four Swords. There are several differences between the A Link to the Past bout in the Dark Palace and this second encounter with the now green beast. A similar strategy is pursued to destroy its mask but after this point, the Helmasaur King produces blue Helmasaurs rather than emits fireballs from its mouth. Once its gem is sufficiently damaged, a second mask will appear and the process is repeated. After this is done, a third eye will appear on the Helmasaur's King's forehead. A Silver Arrow will terminate the beast once and for all.
Green Helmasaur King from the Palace of the Four Sword