I want to write a story that takes place in Nazi Germany but I always hit the same problem how do I write while avoiding historical inaccuracies?
Research. There has to be a ton of material out there for a topic like Nazi Germany. A few inaccuracies are probably unavoidable, and I wouldn't worry about that. I'm sure the majority of readers won't even notice. There are quite a bit of inaccuracies in The Da Vinci Code, yet it's still a bestseller.
Aside from the tons of research into the actual historical facts, you might also want to gain an insight into the mind of the people at the time. Sven Hassel, who was himself a soldier in the Wehrmacht, wrote a series of paperbacks after the war. It's not the most accurate historical source, and Sven and his squad have a survivability rate close to the action heroes you see in movies. But it tells in detail the life of regular soldiers - not SS, sorry - with all of its shortcomings and the way total war dehumanizes even the gentlest of people. Some of the books also show how life was back in Germany itself, for the regular people, not just for the soldiers on the front line. I read them when I was 14 or 16, so I don't really know how I would rate the quality of the writing now. I remember liking them immensely at the time, as it was an easy read and the action never disappointed. From the series, I would recommend The Legion of the Damned, Comrades of War, O.G.P.U. Prison and Assignment Gestapo.