Introduction: We aimed to investigate the risk factors associated with poststroke epilepsy (PSE) among patients with different subtypes of stroke, focusing on age-related risk and time-varying effects of stroke subtypes on PSE development. Methods: A retrospective, nationwide, population-based cohort study was conducted using Korean National Health Insurance Service–National Sample Cohort data. Patients hospitalized with newly diagnosed stroke from 2005 to 2015 were included and followed up for up to 10 years. The primary outcome was the development of PSE, defined as having a diagnostic code and a prescription for anti-seizure medication. Multivariable Cox proportional hazard models were used to estimate PSE hazard ratios (HRs), and time-varying effects were also assessed. Results: A total of 8,305 patients with ischemic stroke, 1,563 with intracerebral hemorrhage (ICH), and 931 with subarachnoid hemorrhage (SAH) were included. During 10 years of follow-up, 4.6% of patients developed PSE. Among patients with ischemic stroke, significant risk factors for PSE were younger age (HR = 1.47), living in rural areas (HR = 1.35), admission through the emergency room (HR = 1.33), and longer duration of hospital stay (HR = 1.45). Time-varying analysis revealed elevated HRs for ICH and SAH, particularly in the first 2 years following the stroke. The age-specific HRs also showed an increased risk for those under the age of 65, with a noticeable decrease in risk beyond that age. Conclusion: The risk of developing PSE varies according to stroke subtype, age, and other demographic factors. These findings underscore the importance of tailored poststroke monitoring and management strategies to mitigate the risk of PSE.