For clarity, I'm going to separate this into two parts: purging the oxygen from the flask, and filling the flask with a particular mixture of gas(es). It's the same idea in both cases, but the first is much easier than the second.
Purging the flask
This is usually done with Nitrogen, as it is one of the cheapest inert gases. You'll take a line from your nitrogen tank, pass it into your flask, and open it. You will need to have a second opening in your flask so pressure doesn't build up, as Richard Terrett describes in his answer. As long as you have the nitrogen flowing, there will be enough positive pressure in the flask that oxygen won't get in from the room. The headspace in your flask should purge quickly, but your culture will take longer. Agitation, either by shaking the flask or by stirring the culture, will make that go much faster.
Establishing a given atmosphere
This is really the same process as above: instead of pure nitrogen, you pump in the mixture of nitrogen and oxygen you want. The system will eventually equilibrate to the mixture you're pumping in. The hard part is getting the mixture you want. When I did this in the past, we used digital mass flow controllers (DMFC's). We would flow oxygen through one DMFC and nitrogen through another. The output of the two DMFC's would mix together before going into the flask. Once you have it set up, it's just a matter of setting the two DMFC's to the mixture you want. The big difficulty with that is that DMFC's are expensive. I don't know how much ours were, but they were made by Bronkhorst, and it looks like that type of DMFC starts at around $2000 each. The nice thing about using DMFC's is that you can control the oxygen composition to within less than 1% by mass.
Depending on how precisely you need to control the mixture, you might be able to get away with a simple flow meter. Again, you would run each gas into its own flow meter, and use that to control the output of each gas. Then you set the two flow rates so that the composition and the total flow rate are what you want them to be. I don't know how precisely you would be able to control the composition, but it might be enough for your application.
Regardless of the atmosphere you're running into the culture, you can either run the purge line into the culture itself, or just into the headspace. I have done it both ways; running it into the culture works faster, but might not be feasible depending on your setup. In one case I worked on, the culture was only a few millimeters thick, and there just wasn't room to stick a needle from the purge line into it. In that case, just pumping gas into the headspace and agitating the culture was sufficient because of how shallow the culture was. In my more recent work, I have a much deeper volume of fluid to purge. In this case, running the purge line only into the headspace probably would be too slow for my purposes, but it's pretty easy to run a needle from the purge line into the fluid without impeding anything else.