A major issue in many applications of Wireless Sensor Networks (WSNs) is ensuring security. Particularly, in military applications, sensors are usually deployed in hostile areas where they can be easily captured and operated by an adversary. Most of security attacks in WSNs are due to the lack of security guaranties in terms of authentication, integrity, and confidentiality. These services are often provided using cryptographic primitives where sensor nodes need to agree on a set of secret keys. Current key distribution schemes are not fully adapted to the tiny, low-cost, and fragile nature of sensors that are equipped with limited computation capability, reduced memory size, and battery-based power supply. This paper investigates the design of an efficient key distribution and management scheme for wireless sensor networks. The proposed scheme can ensure the generation and distribution of different encryption keys intended to secure individual and group communications. This is performed based on elliptic curve public key encryption using Diffie-Hellman like key exchange that is applied at different levels of the network topology. In addition, a re-keying procedure is performed using secret sharing techniques. This scheme is more efficient and less complex than existing approaches, due to the reduced number of messages and the less processing overhead required to accomplish key exchange. Furthermore, few number of encryption keys with reduced sizes are managed in sensor nodes, which optimizes memory usage and enhances scalability to large size networks.