This is best summarized by referring to building code:
Building codes vary, but this seems to be a fairly typical set of rules (at least in the US) such as in the Florida plumbing code. If in doubt, certainly check with your local inspector / authorities.
One of the reasons for these rules is because if a tee were used incorrectly the waste can go backwards and then sit and harden thus creating a clog. With a wye and a 45 stuck in it (or a long sweep 90), then its forced to keep moving.
Although a wye or tee may superficially appear to perform the same job of redirecting flow by 90 degrees, their performance is not the same. In a wye or long-sweep 90 the flow is positively directed in a specific direction. But in a tee there is not a smooth flow transition at the junction. As if a cable were sent down the line at a tee there is a roughly 50/50 chance of going one way or the other; water won't be any different.
A second case to consider is where a vertical pipe serves both as a drain and a vent. Wyes are incorrect for this application. If you use a wye for the vertical for a trap arm, when the trap is installed and if the pipe is properly pitched, it puts the trap weir above the wye inlet which theoretically can cause the trap to siphon: with a wye the fluid passing through the junction would temporarily block air movement which will not occur with a tee.
As somewhat of an exception, typical building codes (e.g., both IPC and UPC) allow a sanitary tee to be installed horizontally provided the straight inlet-to-outlet portion of the tee is vertical and DOES NOT receive the discharge from any fixture (in other words it must be a dry vent).