We show that the all-orders WKB periods of one-dimensional quantum mechanical oscillators are governed by the refined holomorphic anomaly equations of topological string theory. We analyze in detail the double-well potential and the cubic and quartic oscillators. We calculate their quantum free energies to high order in the WKB expansion by using the direct integration of the anomaly equations. We reproduce in this way all known results about the quantum periods of these models, which we express in terms of modular forms on the WKB curve. As an application of our results, we study the large order behavior of the WKB expansion in the case of the double well, which displays the double factorial growth typical of string theory.