Practical clinical optical coherence tomography (OCT) systems require automatic tools for identifying and correcting flaws in OCT images. One type of flaw is the loss of image detail owing to the dispersion of the medium, which in most cases is unknown. We present an autofocus algorithm for estimating the delay line and material dispersion from OCT reflectance data, integrating a previously presented dispersion compensation algorithm to correct the data. The algorithm is based on minimizing the Renyi entropy of the corrected axial-scan image, which is a contrast-enhancement criterion. This autofocus algorithm can be used in conjunction with a high-speed, digital-signal-processor-based OCT acquisition system for rapid image correction.