In this paper, we consider a clustered wireless sensor network where sensors within each cluster relay data packets to nearby clusters using cooperative communications. We propose a cooperative transmission scheme based on distributed space-time block coding and conduct a systematic analysis on the resulting energy consumption. Compared with existing work, our distinctions are twofold: (1) Only sensors that can correctly decode received packets participate in the cooperative transmission, where the number of cooperating nodes depends on both channel and noise realizations; and (2) we use packet-error-rate-based analysis rather than symbol-error-rate-based analysis. This is more realistic since error detection is usually done at the packet level via, e.g., cyclic-redundancy-check codes. Based on the analysis, we further minimize the overall energy consumption by power allocation between the intracluster and intercluster transmissions. With numerical methods, we investigate how energy consumption is affected by the transmit power allocation, the total number of sensors in a cluster, the end-to-end packet error rate requirement, and the relative magnitudes between the intracluster and intercluster distances. Comparisons with direct (noncooperative) transmission schemes demonstrate the significant energy-saving advantage of the proposed cooperative scheme.