There are two ways to see the world famous opera house. One way is to participate in the tours organised by professional guides inside the Opera and see the building, listen the history, go up on the stage and visit the main hall. A trailer of the guided tours about some of the facts that will be discussed on the tours of the Vienna State Opera is on youtube:

The other way, of course, is to get yourself a ticket and attend an evening performance (September-June). Seating tickets are sold in Vienna and on the internet from exactly two months ahead of the date of the performance and range from € 10,- (some of those have limited or no view) to € 240,-. International visitors, however, may order tickets before that by mail. Generally speaking, the cheaper seats sell faster than the expensive ones, but beware of seats at the rear of side boxes which only have a view if you stand on the narrow platform in front of your raised seat! Almost 600(!) standing room tickets at € 3,- and € 4,- are sold 90 minutes before the performance starts . If you want to stand right behind someone who paid €150 for the seat, you'll have to queue much earlier. If you just want to get in to listen and to see the public rooms at less than half the price of a guided tour, you have a good chance of getting a ticket without queuing for long.
Step by step instruction on how to order tickets can be found here:

Some more information on the STANDING ROOM tickets: You head for the door in the middle of the left flank of the building (streetname: Operngasse), under the arcades. If the door is still locked, the queue forms outside, if it's open, the queue moves in and when it's full inside, the end of the queue is outside again. There is only one counter and it starts selling tickets 80-90 minutes before curtain time. Now you choose between Parterre (€ 4,-), Balkon and Galerie (€ 3,-) places. One ticket per person only! Parterre is downstairs, in the far back with a good frontal view of the stage, but it can get very crowded and only the first 100 or so end up with a rail in front to hold on to. Balkon (standing room on the sides only) is the second highest and Galerie (standing room all around, also in the center) the highest level. Both feature excellent acoustics and rails for everyone to hold on to.

Once you have your ticket, you have to queue again. There are now three queues near the different standing rooms, those for Balkon and Galerie are in the staircases. Staff will help you to find your way. About 45 minutes to curtain time, you will be let in the standing room area. Places are not numbered, therefore you have to MARK YOUR PLACE WITH A SCARF or something similar by making a knot on the lower rail in front of you. If you don't have anything to mark your place, stay there or you'll loose it. To be sure, remember your neighbours and then you may leave the standing room until curtain time. Walk around public rooms, have a snack or just sit down somewhere. When you get back, find your place by looking for your scarf and your neighbours. Regular patrons can get rather harsh when they find someone sneaking in on a place he didn't mark!

Dress code is informal in the standing room (but definitely no shorts or sandals for guys), but if you want to walk around the public rooms, you might feel comfortable wearing something more elegant or at least dark colour. It can get rather hot in the standing room, so be prepared to get out of a layer of clothes.

How long before you have to queue up depends on a lot of things like on the opera, the cast, if it's a weekend or weekday, new production etc. The standing room hardly ever sells out (almost 600 places!), but the earlier you come the better you'll see from your place. If you come three hours before curtain, this will normally enough to secure you a very good place. Also, you can pass by and check out the queue earlier and then decide whether to join it or to sit down for coffee and cake nearby before queueing up.