Once you have a refined research topic you will need to develop the research question. At the beginning of the research process you will ask questions like who, what, when, and where. The research paper however, needs to address a problem, not merely relay factual information.
A thesis statement is 1 to 2 sentences at the end of the first paragraph that concisely presents to the reader a summation of your argument and its significance.
The point at which you formulate your thesis statement depends. Certainly, if you have chosen a topic of inherent interest to you it is likely that you are embarking on your research with certain assumptions and/or expectations. Moreover, having a plan in mind of how your paper will come together will help keep your research organized. However, be cautious of rigidly committing to a claim too early.
Be mindful of the natural human tendency toward confirmation bias. If you set out to prove something, it is unsurprising that you will find sources (especially commercial websites) which confirm that belief. This will make it that much easier to disregard any contradictory evidence or reasoned, dissenting opinion. Good research always engages with opposing arguments.
Furthermore, as your research progresses, the empirical evidence and preponderance of research may or may not support your original claim. What your research turns up may require that you modify your thesis accordingly.
UNC Writing Center, Thesis Statements Handout