Pin-fin heat sinks are widely employed to dissipate heat from power devices under natural convection conditions. To improve heat dissipation performance, optimization of the fin height distribution was conducted in this study. In order to enhance optimization efficiency, we propose a dynamic surrogate model that integrates machine learning, iteratively sampling and training until the convergence criterion is met. Compared with traditional surrogate models, the dynamic surrogate model significantly reduces the prediction error of the optimal result, proving more efficient and yielding superior outcomes with fewer samples. By optimizing the fin height distribution, the heat sink thermal resistance was minimized without increasing mass. Subsequently, an experimental bench was developed to compare the heat sink's total thermal resistance pre- and post-optimization under natural convection conditions. Experimental results demonstrate that within the input heat flux range of q = 500–1200 W/m2, the optimized heat sink's total thermal resistance is diminished by 6.08% to 8.01%, without any mass increment, which confirms the dynamic surrogate model's efficacy in natural convection scenarios. This study elucidates the design principles governing the height distribution of pin-fins of heat sinks under natural convection, and provides a significant insight for guiding the design of pin-fin heat sinks.