What triggers the switch between aerobic and anaerobic respiration?
The simplest method of control of metabolism is by substrate concentration. So if the concentration of NADH and pyruvate is low, lactate dehydrogenase cannot function. When they build up it can and will. 



The situation is more complicated than this, because pyruvate will only build up if it is not converted to acetyl CoA by the pyruvate dehydrogenase complex (see Berg et al. section 17.1.1):

 

Although the overall reaction is oxidative, and ultimately requires NAD+, the latter is not directly involved in the initial irreversible reaction. It is presumably for this reason that the reaction is also controlled, either allosterically (in bacteria) or by phosphorylation (in mammals). In either case the regulators are the small molecules the concentration of which is altered by the lack of oxygen: NAD+/NADH and ATP/ADP. The figure below and its legend is also from Berg et al. (section 17.2.1) — available through NCBI Bookshelf.



[The complex is inhibited by its immediate products, NADH and acetyl CoA. The pyruvate dehydrogenase component is also regulated by covalent modification. A specific kinase phosphorylates and inactivates pyruvate dehydrogenase, and a phosphatase actives the dehydrogenase by removing the phosphoryl (group). The kinase and the phosphatase also are highly regulated enzymes.] 

The actual situation is quite complex and this is something of a simplification.