Head computed tomography (CT) plays an important role in the comprehensive evaluation of acute stroke. Photon-counting spectral detectors, as promising candidates for use in the next generation of x-ray CT systems, allow for assigning more weight to low-energy x-rays that generally contain more contrast information. Most importantly, the spectral information can be utilized to decompose the original set of energy-selective images into several basis function images that are inherently free of beam-hardening artifacts, a potential advantage for further improving the diagnosis accuracy. We are developing a photon-counting spectral detector for CT applications. The purpose of this work is to determine the optimal beam quality for material decomposition in two head imaging cases: nonenhanced imaging and K-edge imaging. A cylindrical brain tissue of 16-cm diameter, coated by a 6-mm-thick bone layer and 2-mm-thick skin layer, was used as a head phantom. The imaging target was a 5-mm-thick blood vessel centered in the head phantom. In K-edge imaging, two contrast agents, iodine and gadolinium, with the same concentration (5 mg/mL) were studied. Three parameters that affect beam quality were evaluated: kVp settings (50 to 130 kVp), filter materials (Z=13 to 83), and filter thicknesses [0 to 2 half-value layer (HVL)]. The image qualities resulting from the varying x-ray beams were compared in terms of two figures of merit (FOMs): squared signal-difference-to-noise ratio normalized by brain dose (SDNR2/BD) and that normalized by skin dose (SDNR2/SD). For nonenhanced imaging, the results show that the use of the 120-kVp spectrum filtered by 2 HVL copper (Z=29) provides the best performance in both FOMs. When iodine is used in K-edge imaging, the optimal filter is 2 HVL iodine (Z=53) and the optimal kVps are 60 kVp in terms of SDNR2/BD and 75 kVp in terms of SDNR2/SD. A tradeoff of 65 kVp was proposed to lower the potential risk of skin injuries if a relatively long exposure time is necessarily performed in the iodinated imaging. In the case of gadolinium imaging, both SD and BD can be minimized at 120 kVp filtered with 2 HVL thulium (Z=69). The results also indicate that with the same concentration and their respective optimal spectrum, the values of SDNR2/BD and SDNR2/SD in gadolinium imaging are, respectively, around 3 and 10 times larger than those in iodine imaging. However, since gadolinium is used in much lower concentrations than iodine in the clinic, iodine may be a preferable candidate for K-edge imaging.