Firstly, I don't think there is "one Best Way" that could apply to all programmers: as with many things in life, it depends. I can only answer based on what works for me.
Secondly, 'burnout' means slightly different things to different people in my experience so far. I'm going to assume you mean suffering mental or physical health problems (minor or more severe) caused by your job. Please clarify if you mean something different!
On to some answers.
A commonly-given answer to this is that you should maintain a "work/life balance". That's a fair answer, but very vague. For me, this means things like:
* Limiting how many hours per day, and per week, you normally spend in your place of work (company offices, home office room, whatever). It can be tempting to do 'just one more hour' if you are enjoying the work, but one more and one more and one more is a slippery slope. You can make exceptions for truly special occasions e.g. some big sales pitch that needs a bunch of extra effort in the last few days: but don't let those exceptions become the norm.
* Limiting how much you engage the 'work' part of your brain outside of those working hours. Trying to remain available and responsive to work communications (email, instant message, etc) 24/7 is very draining in the long run. It's one thing to be hyper-available on special occasions (like above), but in general, consider trying to keep evenings and weekends free of any work activity. This seems to be less and less common in workplaces I've experienced, but I think it makes a big difference to my well-being, and nobody has ever objected to me not reading an email until Monday.
* Choosing carefully what you do with your non-working hours. Sleep enough. Socialize with non-colleagues (non-work friends can be great to have a casual grumble about work to!). Find a hobby that is very different to work: if you program at work and program in your spare time, you'll struggle to see the bigger picture and relax. Exercise regularly (walking, running, or biking to and from work is an EXCELLENT idea if you can do it). Eat a balanced, healthy diet at least _most_ of the time; nothing wrong with treating yourself to Friday night pizza, but don't have takeout every night.
I also think you should avoid feeling like you're competing with colleagues. In some senses and in some companies, you might be; but that doesn't mean you have to try to out-work them in terms of hours. Employers generally care about quality and consistency at least as much as quantity of output - and they probably care about a bunch of other, softer, skills as well as your main programming output. Talk to your immediate manager regularly about your performance and get their feedback. So long as they don't have concerns, don't invent any to worry about.
Be careful how you view and handle work deadlines. This is especially relevant for people just out of college. Deadlines in the real world usually aren't like assignment deadlines at school. School deadlines are fairly fixed, because professors want to see what you can do _in that time_. Most work deadlines are more like guesses for how long stuff's gonna take.
Think about this. You're in school for what, maybe 17 years? With pretty long vacation breaks thrown in. Then in work for at least 40-45 years, maybe more - with much less vacation time. It's a marathon, not a sprint. Very occasionally, work deadlines crop up that really justify pouring everything you've got into; the rest of the time, you should aim to be working at a consistent, effective pace, and if the deadlines aren't achievable that way, something's gonna change. Don't slack: work _hard_ all the time, but hard like a marathon runner is working hard, not like a sprinter. Don't let the deadline stress you out: talk to your manager(s) about them. Tell them what seems reasonable and achievable, and what doesn't - and why. They will probably either shift the deadline, lower the expectation, or add more programmers.
If you feel like you're heading towards burnout, don't keep it to yourself. Talk to people, in person, the sooner the better. Talk to your manager: they might well have been in your shoes, and have good timely advice. It's in their interests to get you back on a good footing. Talk to your non-work friends: they might have perspectives from other careers. Talk to your parents - it's surprising how helpful that can be, even if they have no useful advice! Talk to a doctor or therapist too if you are concerned about your mental health.
I will finish by observing that not all employers care equally about their employees' well-being and avoiding burnout. If you find yourself working for an employer who seems to disregard many or all of the above considerations, and seems to be demanding that you head towards burnout... step back and consider if that is the right place for you to continue working. Ask others for advice in the particular situation. Remember there are always other jobs!