Is there an ethical obligation to make author order reflect conventions in your field? In some fields, authors of a paper are not ordered alphabetically; rather, their order carries some meaning related to the authors' contributions to the work. See What does first authorship really mean? for more details. In these fields, readers of a paper make certain assumptions about the role of each author, depending on their placement in the author list.

For example, in my field, the first author is typically the person who was the "main" contributor, and the last author is typically the person with the greatest supervisory role or the head of the research group where the research was carried out. The middle authors are the least important. Thus if my name is first in the author list, readers of my paper who are familiar with conventions in the field will assume that I was the main contributor to the work.

Under these circumstances, is it ethically problematic to use a different author order, assuming this is acceptable to the authors? (Putting aside issues of who does and doesn't deserve to be an author; let's assume all of the authors have sufficient contribution to be considered authors, and we are only concerned with order.) Do I have an ethical responsibility to protest if this happens on a paper where I am a co-author?

For example, suppose I co-author a paper with an undergraduate research assistant, and I do most of the work. According to conventions in my field, I should be listed as the first author. But maybe I don't really need this first-author paper, and my undergraduate student does (it would really help him get into graduate school), and I'd happily give up first authorship so that he can have it. Is this ethically problematic?

Or, suppose a senior author, Prof. Z, wants to be last on the author list. If Prof. Z is listed as the last author, the paper will be thought of as having "come from Prof. Z's group". The author who really should be last (based on having been the main supervisor contributor), Prof. Y, is OK with this arrangement (as a favor to Prof. Z, or to avoid an argument). Is it problematic to give last authorship to someone who doesn't really deserve it in this case, and should other co-authors insist on the conventional ordering?

The potential ethical issue is that readers may be misled about the role of the authors, if the order doesn't reflect the contributions that will be assumed based on conventions in the field. I'm not sure if this is a real problem, or if I'm overthinking it, though.
I don't think you're overthinking this. If your authorship decisions are made with the intention to mislead others about the respective roles and contributions of the various authors, then yes, I'd say that is pretty clearly unethical. For instance, your first example can be reasonably interpreted as a mild form of gift authorship.

It's also important to remember that authorship of papers can have real consequences to people's careers. An example that comes to mind is the Alpher-Bethe-Gamow paper, a famous paper in cosmology that provided one of the early theoretical analyses supporting the big bang theory. The work that led to the paper was part of Ralph Alpher's dissertation work under George Gamow. Gamow, who was already a well-known physicist at the time, had the idea to add the name of his friend Hans Bethe (an even more famous physicist) as a coauthor purely as a joke to make the list of authors sound like "alpha-beta-gamma". This didn't work out so well for his student Alpher. The Wikipedia article I linked to above says:


  Alpher, at the time only a graduate student, was generally dismayed by
  the inclusion of Bethe's name on this paper. He felt that the
  inclusion of another eminent physicist would overshadow his personal
  contribution to this work and prevent him from receiving proper
  recognition for such an important discovery. He expressed resentment
  over Gamow's whimsy as late as 1999.


Simon Singh (in whose wonderful book "Big Bang: The Origin of the Universe" I originally read this story), also writes in this article:


  Gamow and Bethe were then both famous names in the world of physics, so scientists assumed that it was they who had done the bulk of the work, which meant that young Alpher was ignored. In the decades ahead, the formation of helium in the wake of the Big Bang would become one of the key pieces of evidence to support the Big Bang hypothesis, but few would remember Alpher's contribution.


To summarize, since the conventions surrounding author order vary across disciplines and are inherently somewhat vague, someone who wants to manipulate author order in one of their papers to give a small boost to someone's career will probably have enough plausible deniability to get away with it without anyone making a fuss. But it shouldn't be done without a very good reason, would be unethical if done out of a dishonest motivation, and can be potentially harmful even if done for innocent or whimsical reasons.