Ticket machines in the station will sell you a ticket, or the ticket office on your right as you enter the station (facing platform 12) will sort you out if you have any concerns.
You can get a completely open ticket if you need which will work on any companies train at any time if you need the flexibility, or ones limited to set operators and times to get it for cheaper.
You can buy tickets just minutes before you travel at the station so don’t worry about that.
As someone else said though. Be aware of strike action. Arriva and Go North East have direct bus services into Durham from Eldon Square bus station if you need it, but they are significantly slower than the train.