Deficits in cognitive control, whether intrinsic or arising from drug use increases relapse vulnerability and risk for out of control drug use. In susceptible populations, women tend to transition to addiction faster and experience greater difficulties remaining abstinent 1,2 however, what drives this is unknown. Even when taken as prescribed, opioid-based pain therapies carry a risk of misuse and addiction. Thus, identifying adaptations responsible for reduced cognitive control and how intrinsic factors like biological sex influence risk for opioid abuse provides an opportunity to enhance relapse mitigating therapies and reduce susceptibility to opioid use disorders. Decreases in intrinsic excitability (hypoexcitability) of frontal cortex pyramidal neurons has been linked with loss of cognitive control in a variety of mental disorders, including addiction, however underlying mechanisms of this cortical dysfunction are poorly characterized. We show that self-administration of the opioid, remifentanil, causes a long-lasting decrease in ex vivo excitability but augments firing capacity of pyramidal neurons in the prelimbic cortex. This phenomenon occurs faster in females and aligns with a shift in synaptic drive towards inhibition and a significant impairment in cognitive flexibility. Further, compensating for this hypoactive state using chemogenetics protected against inflexibility that results from opiate self-administration. These data define cellular and synaptic mechanisms by which opioids and perhaps other drugs of abuse impair prefrontal function and cognitive control and have implications for sex differences in opioid addiction vulnerability.