An Approximate Inference Approach to Temporal Optimization in Optimal Control