Imperfect prediction of driving environments imposes significant challenges to motion planning for autonomous road vehicles. Contingency planning addresses these uncertainties by maintaining multiple candidate trajectories that share the same initial segment and branch later to account for different evolutions of the driving environment. Existing approaches typically determine the branching time of the contingent trajectories heuristically, which may lead to conservative or even infeasible plans. We propose a mixed-integer programming formulation of contingency planning that optimizes the branching time as a decision variable. Our approach is implemented within a receding-horizon planning framework and evaluated using the CommonRoad benchmark suite. Numerical experiments demonstrate that optimizing the branching time ensures feasibility while improving the quality of contingency plans. Our contingency planner is published as open-source code at https://github.com/CommonRoad/miqp-contingency-planner.