Sometimes, you're writing about something you don't know intimately. This can lead to some easy errors that people who are well-versed in your subject will quickly spot.
So, undoubtedly, there will be some required research.
But when do you do this research? Before you start writing? When you reach that part of your story? When you're editing?
Different writers will approach research different ways, but keep this in mind no matter whatever your preference: Research when it will help you make the story more genuine.
If you're setting your story in another country, you're going to have to learn about that country before your writing as it will impact everything: weather, clothes, accents, etc.
If you are just dropping in a character who practices a profession you don't know much about, you can make sure your details are right later.
If you're writing a novel where a character's medicine has a big impact on their actions and lives, you might have to change a lot of what you've written if you don't know the side effects, timing, and requirements of that medicine. For example, if you have someone on a certain medicine and they do something vital when they are drunk, it'll be problematic to later learn that they can't drink when on that medicine. That might have a big impact on what you've written and might require you to make a number of rewrites.
Only you know how important a detail is to your story. Decide, based on detail importance, how much research you need to do now and later.