The rapid advancement in the era of wireless applications and services has made huge demand of spectrum resources. The cognitive radio is a new concept that can utilize radio spectrum resources efficiently and sufficiently. The spectrum sensing is a function of cognitive radio. This paper develops an energy detection algorithm based on wavelet packet transform for spectrum sensing. The performance of the proposed algorithm is analyzed under varying Signal to Noise Ratio for different number of samples, probability of false alarm, level of decomposition and wavelet function used in wavelet packet transform. The best possible configuration of parameters is obtained by simulations, which provides most accurate detection of the primary user signal.