The increasing prevalence of lung diseases caused by infections such as Pneumonia and COVID-19 highlights the urgent need for accurate and efficient early detection methods. This study aims to improve the classification performance of chest X-ray images using the DenseNet-169 deep learning architecture, with a focus on hyperparameter optimization through Bayesian Optimization. The dataset used consists of 3,000 chest X-ray images—1,000 each for Normal, Pneumonia, and COVID-19 classes—sourced from Mendeley Data and split with an 80:20 ratio for training and testing. The baseline DenseNet-169 model initially achieved an accuracy of 96.837%, although slight overfitting was observed. By applying Bayesian Optimization, several key hyperparameters—such as learning rate, number of epochs, batch size, and kernel size—were systematically optimized. The optimized model demonstrated an improved accuracy of 97.33%, with the most notable increase in the recall score of the Normal class, which rose by 3.19% to 97%, effectively reducing the false negative rate for healthy cases. In addition, the final model recorded a precision of 99% and a specificity of 99.50% for the COVID-19 class, indicating a strong discriminative capability in identifying critical conditions. Analysis of the training and validation curves showed good convergence, confirming the effectiveness of the optimization in reducing overfitting and enhancing the model's generalization ability. Overall, the results of this study demonstrate that the application of Bayesian Optimization significantly enhances the performance of DenseNet-169 in chest X-ray image classification. The resulting model is more balanced, robust, and reliable, showing great potential for integration into AI-based automated diagnostic systems in the field of respiratory healthcare.