The integration of security-aware and energy-optimized routing in Wireless Sensor Networks (WSNs) is crucial for establishing a robust, secure, and energy-efficient communication framework while maintaining the Quality of Service (QoS) requirements of the application. Furthermore, energy efficiency which is a critical concern due to the limited power resources of sensor nodes, seeks significant research attention. Optimized routing strategies enhance network longevity by minimizing energy dissipation during data communication. To address above issues, this paper proposes a novel Security-aware Red Fox Optimization (RFO)-based Cluster-based Routing (SECR) algorithm, which facilitates secure and energy-efficient data transmission among sensor nodes. The RFO algorithm is employed to dynamically select the optimal Cluster Head (CH) based on energy metrics and network topology. For secure data transmission, an adaptive Advanced Encryption Standard (AES) is implemented at the selected CH, ensuring data confidentiality before forwarding the encrypted information to the sink node. Performance evaluations through extensive simulations demonstrate that the proposed SECR protocol outperforms existing state-of-the-art routing techniques in terms of security robustness, energy efficiency, and network lifetime.