Generally, you need to have a good feeling for the direction you want to go into when you apply to graduate school, but you don't have to be 100% certain. In some schools, you spend your first year doing coursework and don't have to decide on a supervisor/thesis topic right away. Others base their admissions on who's going into what fields.
There's no perfect test for figuring this out. Most people meander through the system making choices among the best options available to them at the time, in my experience.
What I think is important is to make sure in your upper graduate years that you take a diverse range of courses so that you're exposed to subjects that you're interested in. Of course this isn't easy when you're interested in everything, but it gives you a better basis for a decision then sticking to a narrow range of subjects.
Also important is attending departmental colloquia. Often, the bulk of these talks fly over the heads of undergrads, but in most cases the introduction should be set up to introduce the field, the relevance of the problem being studied, and the approach that's used to solve it. Take the opportunity to chat with speakers after their talks - even if all you ask are questions like: How do you enjoy this field? or Where will this field be going in the future?
When I was a grad student a small group of us organized a series of talks aimed at undergrads with the specific idea being that the talks were meant to introduce a given field and the research at an approachable level. There's no reason why you couldn't do something similar.
Finally read. Try to read through review articles, or articles in journals like Physics Today or Science or Nature.