A new method to improve the bit error rate (BER) performance by optimising the bit energy is proposed in this study. This method is mainly based on a formula derived from the union bound that can estimate the BER for every bit in the codeword sequence. Then by mathematical optimisation and assisted with a BER distribution, the energy for every bit can be optimised so that the average BER achieves the minimum value. Compared with other methods, this method considering all the codewords with minimum Hamming weights and their multiplicity to each bit of the codewords. The simulation examples show that the average BER is improved not only at high signal-to-noise ratio (SNR), but also at low and moderate SNRs.