The determination of optimal financing (optimal capital structure or optimal mix of funds) for corporations is important for efficient corporate governance. Some optimization problems in determining optimal financing for corporations include optimal control, involving a dynamic system with switching times. An optimal control model for corporate finance is presented here and the analytical results of the model are also reported. Computational approaches to the study of optimal corporate financing are not well known in the literature. This paper develops a new computational method where switching times are considered as variables in the optimal dynamic financing model, which is represented by a second order differential equation. A new computer program named CSTVA (Computer Program for the Switching Time Variables Algorithm), which can compute optimal financing models with switching time, is also developed. Optimal financing implications of the model in the form of optimal switching times for changes in financing policies and the optimal financing policies are analyzed.