References play a crucial role at all stages of your academic career. They will be considered in your application for a PhD program, in applications for doctoral and post-doctoral fellowships, and in academic job applications. (The role they play in a non-academic job search may be very different.)
Obviously you want referees who will say great things about your work and your potential. There are also some expectations about who you will list as referees. Not having those people can send as strong a message as having a not-very-supportive letter.
The foundation of a good reference is a solid professional relationship with the referee. It is not enough that they have read and liked what you have written or presented. Ideally they should be familiar with your work habits and your intellectual interests and abilities more generally. At least one of your referees should be someone with whom you have discussed your career goals and how different aspects of your work contribute to those.
Your dissertation supervisor is one of the expected referees. In addition to having read your work, your supervisor knows whether you keep your commitments (e.g. to submit work), how you respond to criticism and advice, and how much revision goes into the finished work others see. They also have a sense of the depth and breadth of your intellectual interests even if most of those have not developed into publicly presented work. Some advisors will be more proactive in providing career advice and mentoring, but you should seek their advice and support early.
Build and maintain relationships with others who might provide references. You don’t need to see them frequently, but there should be ways to maintain contact. Seek advice relevant to their area of expertise. Let them know about conference presentations or papers you are submitting. Ask if they would like you to send copies.
If you have chosen a referee specifically for their knowledge of your teaching abilities, give them an opportunity to observe your teaching and give constructive feedback. Don’t wait until you urgently need a reference letter. Build this kind of relationship with professors you TA for. If they aren’t willing to mentor your development as a teacher, they are unlikely to be a good referee for this aspect of your work.
As you progress in your career, you will want to bring in new referrees. Build these relationships so that you are in a position to ask for references when you need them. These relationships may start with meeting at a conference, or even in a job interview. A sense that someone really liked your work is a signal to expand your network to include that person. Once a solid relationship is developed, you may ask them to provide a reference when you need one.
Never list someone as a referee without requesting their permission. You should also inform your referees of every application on which they are named and offer to provide them with relevant material.