Common Spatial Patterns (CSP) has been proven to be a powerful and successful method in the detection of event-related desynchronization (ERD) and ERD based brain–computer interface (BCI). However, frequency optimization combined with CSP has only been investigated by a few groups. In this paper, a frequency-weighted method (FWM) is proposed to optimize the frequency spectrum of surface electroencephalogram (EEG) signals for a two-class mental task classification. This straightforward method computes a weight value for each frequency component according to its importance for the discrimination task and reforms the spectrum with the computed weights. The off-line analysis shows that the proposed method achieves an improvement of about 4% (averaged over 24 datasets) in terms of cross-validation accuracy over the basic CSP.