It may seem tough to decide whom to approach about writing you a letter of recommendation. But when you think about the key elements of a good reference, it narrows down the playing field: You want someone vouching for you who is familiar with your work, holds you in high regard and, ideally, can include personal anecdotes in the recommendation letter. Not only that, they must be in a role that led them to be able to assess your skills and other attributes.
Since no one person knows everything about you, and many jobs or academic pursuits require two or three letters of recommendation, it's a good idea to choose several references that complement one another. For example, one could write about your academic strengths, another could focus on your on-the-job problem-solving skills and a third could testify to your character. The letters combined create a more complete picture of you as a person, scholar or employee.
One pitfall to avoid is assuming that the letters that pack the most punch come from people who hold lofty titles or top positions such as your company CEO. Sure, authority is important, but not if the tradeoff is a letter that clearly reveals that the writer does not have meaningful insight into you or your experience and goals. That being said, it's true that letters often have more impact when they are written by someone high on the food chain. So, if you have such a contact, don't hesitate to approach that person. In academic settings, professors have more clout than associate professors or lecturers, and professionally you'd be better off getting a letter from a manager or supervisor than a colleague.
Keep in mind that a recommendation letter will be most relevant if it comes from someone closely affiliated with the field you're pursuing. For example, if you're applying to an MBA program, approach one of your business professors, not your history teacher. If you want a job in sales, ask a leader in your company's sales department, not purchasing. Depending on the position, you might not stop at asking supervisors and co-workers to write you a reference letter; you could also ask for the perspective of a subordinate.
Try to ask for reference letters from people who you know are articulate and comfortable with the written word. It's also good (especially in the case of employment and academic letters) if the person has written letters of recommendation previously.
Make sure that the person you ask is comfortable writing a letter for you. For example, it would not be a great idea to ask someone with whom you'd had a professional or personal run-in, or a personality conflict, or, worse, fired you. If you're uncertain how the person would portray you in a recommendation letter, you could ask outright, but be sensitive about putting him or her in an awkward position.
Index of letter of recommendation templates