When talking about writing flashbacks, you'll find a lot of people really, really hate them and will tell you to never use them in your entire writing career. These people are a little nuts, but they're not completely wrong. Flashbacks, when done poorly, are confusing, take readers out of the scene, and leave them wondering what the hell just happened. Here are a few tips on how to write them effectively:
Keep it short. When flashbacks are too long, returning to the story's present can be very confusing. Oftentimes, readers will forget where they left off. If you need a flashback in the middle of the scene, try to keep it to one to three paragraphs so the audience doesn't forget where they were. Junot Diaz does this wonderfully in his book Drown, so look to him for good implementation.
Weave flashbacks into the context. Placement of flashbacks is crucial, as that will dictate how disruptive they are. Make sure the flashback is relevant to the actions taking place or the information being presented. For example, Cherifa induces her own flashbacks in Death Defiant as a way to cope with being tortured. The flashbacks are long, but since they're the scenes playing within her head during the context of the torture, it doesn't disrupt the reader too much when the story jumps from present to past.
Use time markers to orient us.This is a rather simple fix. Using some simple words such as "last summer" or "August of 1903" in the first sentence of the flashback work as sign posts for the reader, warning them that what they're about to read is not set in the story's present. This will ease the disorientation that comes with flashbacks and ensure there's no confusion about what's going on.
Above all, remember to use flashbacks sparingly as they are distracting. Keep the story in the moment as often as you can and only use flashbacks where absolutely necessary.