Synthetic Aperture Radar (SAR) is an active microwave sensor with all-day/night and all-weather detection capability, which is crucial for detecting surface water resources. Surface water-body such as rivers, lakes, reservoirs, and ponds usually appear as dark areas in SAR images. Accurate and automated extraction of these water bodies can provide valuable data for the management and strategic planning of surface water resources and effectively help prevent and control drought and flood disasters. However, most deep learning-based methods rely on manually labeled samples for model training and testing, which is inefficient and may introduce errors. To address this problem, this paper proposes a novel water-body detection method that combines optimization algorithms and deep learning techniques to automate water-body label extraction and improve the accuracy of water-body detection. First, this paper uses a swarm intelligence optimization algorithm, Dung Beetle Optimizer (DBO), to optimize the initial cluster center of the K-means clustering algorithm, which is called the DBO-K-means (DK) method. The DK method divides the training images into four categories and extracts the water bodies in them to generate the water-body labels required for deep learning model training and testing, and the whole process does not require human intervention. Then, the labels generated by DK and training data set images are fed into the Classifier–Optimizer (CO) for training. The classifier performs a dense classification task at the pixel level, resulting in an initial result image with blurred boundaries of the water body. Then, the optimizer takes this preliminary result image and the original SAR image as input, performs fine-grained optimization on the preliminary result, and finally generates a result image with a clear water-body boundary. Finally, we evaluated the accuracy of water-body detection using multiple performance indicators including ACC, precision, F1-Score, recall, and Kappa coefficient. The results show that the values of all indicators exceed 93%, which demonstrates the high accuracy and reliability of our proposed water-body detection method. Overall, this paper presents a novel DK-based approach that improves the automation and accuracy of deep learning methods for detecting water bodies in SAR images by enabling automatic sample extraction and optimization of deep learning models.