The Internet of Things (IoT) has transformed various aspects of human life nowadays. In the IoT transformative paradigm, sensor nodes are enabled to connect multiple physical devices and systems over the network to collect data from remote places, namely, precision agriculture, wildlife conservation, intelligent forestry, and so on. The battery life of sensor nodes is limited, affecting the network’s lifetime, and requires continuous maintenance. Energy conservation has become a severe problem of IoT. Clustering is essential in IoT to optimize energy efficiency and network longevity. In recent years, many clustering protocols have been proposed to improve network lifetime by conserving energy. However, the network experiences an energy-hole issue due to picking an inappropriate Cluster Head (CH). CH node is designated to manage and coordinate communication among nodes in a particular cluster. The redundant data transmission is avoided to conserve energy by collecting and aggregating from other nodes in clusters. CH plays a pivotal role in achieving efficient energy optimization and network performance. To address this problem, we have proposed an osprey optimization algorithm based on energy-efficient cluster head selection (SWARAM) in a wireless sensor network-based Internet of Things to pick the best CH in the cluster. The proposed SWARAM approach consists of two phases, namely, cluster formation and CH selection. The nodes are clustered using Euclidean distance before the CH node is selected using the SWARAM technique. Simulation of the proposed SWARAM algorithm is carried out in the MATLAB2019a tool. The performance of the SWARAM algorithm compared with existing EECHS-ARO, HSWO, and EECHIGWO CH selection algorithms. The suggested SWARAM improves packet delivery ratio and network lifetime by 10% and 10%, respectively. Consequently, the overall performance of the network is improved.