tl;dr: Assuming that he knew about the 4th Infinity Stone stone before his vision, he most likely learned about it sometime off-screen, between Guardians of the Galaxy and Avengers: Age of Ultron.
First of all, we can assume that Thor probably has fairly in-depth knowledge of the Infinity Stones, given that his friends do. This seems to be part of the normal education on Asgard: Sif not only calls them by name, but knows that Tesseract and Aether are both Stones and knows not to keep them all in one place.
Thus, when he saw the Infinity Stones in his vision, he would certainly have recognized them. However, as far as we know, his vision is merely a manifestation of his worst fears. While it makes sense, given the events of Avengers and Thor 2, that the Infinity Stones reemerging would have been his biggest fear. And, later on when he goes to the Waters of Sight, he would have learned everything everything else he needed, e.g. that it was the Mind Stone, and that Vision needed to exist. But the one thing he did see in his vision, that he shouldn't have know, was that there were 4 stones. How did he know to be afraid of four, not two (which he knew of) or three (if he suspected what the scepter was) or six (which is all of them)?
The clue is what he says at the end of the movie: that four of the stones have appeared in recent years. This implies that he knows of four specific cases where an Infinity Stone was active. On-screen, he's only encountered the Tesseract and Aether, and now the Mind Stone. So, he must have learned about the events of Guardians of the Galaxy at some point off-screen.
Thor's a high-ranking Asgardian noble, he probably hears things. The destruction of Knowhere, the attack on Xandar, and the fact that an Infinity Stone was involved are all big newsworthy events. The Asgardians obviously have a working relationship with the Collector, and they have shown themselves to be well-versed in galactic history and lore, and willing to get involved in "peacekeeping" missions when needed.
The news of an Infinity Stone is exactly the kind of thing that would likely make its way to Asgard, either officially (maybe the Nova Corps has a diplomatic relationship with Asgard, we don't know), or via the rumor mill.