Samarra is about 125 km north of Baghdad on the main road to Tikrit and Mosul. By car the journey takes around two hours from central Baghdad, depending on traffic and road conditions. Shared taxis and minibuses from Baghdad's Al-Shawaka bus station cover the route regularly, and this is the most common way for independent travellers to arrive.
There is no commercial air service to Samarra. The nearest airports are Baghdad International, about 140 km to the south, and Tikrit (Saddam International, now operated by the Iraqi Air Force), which is not open for civilian use.
Security conditions on the road have improved considerably since the worst years of the insurgency, but it is worth checking current conditions with recent travellers or your country's foreign ministry before making the journey. The drive passes through Taji and through areas that were contested as recently as 2014–2017 during the conflict with ISIL.