Link gets the Earth Element after beating a regular Green Chuchu on Deepwood Shrine, but, as he is Minish-sized, he will be giant. This first element is only infused at the White Sword later on the game.
Link gets the Fire Element after beating its guardian, Gleerok. This element, together with the Earth Element, when infused in the White Sword, will increase the strength of his sword.
Link gets the Water Element early in the dungeon, by melting the ice surrounding it. But when Link melts it, it will unfreeze Big Octo, the boss of the dungeon. He will steal the element, thus forcing Link to beat him in order to get it back. When infused, the White Sword will get a power upgrade.