Most graduate students who publish do so as co-authors on articles with more senior researchers and faculty members. This is fine. Be open to sharing credit with others, even if you feel you have made a disproportionate contribution to the research. Contributions can be made in different ways and at different levels. With all of the above in mind, Ph.D. advisers in most science and engineering fields recommend that a graduate student have at least one paper in which the student is named as the first author.
Many professors also like to see their students as co-authors of one other paper.
Usually it is the person who conceived, designed, and carried out the experiments and then took the lead in writing up the results. Since Ph.D. dissertations, by definition, represent an original contribution to the field by the student, it stands that most papers resulting from such dissertations should have the graduate student as the first author. However, different norms do exist within different disciplines with respect to whose names appear as authors and in what order. In some cases, the lab director's name goes on every paper, says Donald Kennedy, editor of Science. In population biology it is the people who actually do the work, usually graduate students, who are the only names on the paper.