Had the idea vs. did the work: Who should be the lead author? Dr. A came to Dr. B asking for research ideas. Dr. B gave him a thesis, explained its value, why it's plausible, and how to test it.  Dr. A liked this, got Student C to do the work, and managed the work.

Now, it's time to publish their results.  How should they determine the lead authorship?
The lead author should be the person who carries out the bulk of the research work—including the planning, execution, and writing. 

If the student C is the one responsible for carrying out the experiments and writing the paper, then C should be considered the primary agent of the paper. 

Who should be the "final" author is a different matter. I would suspect that this really should be professor B, who had the original idea. The role of doctor A is only as research manager, so his role is nominally weaker than that of either B or C in this process. So, ultimately, barring other negotiations and arrangements to the contrary, it should be:


  Student C, Doctor A, Professor B.


If there is some other distribution of roles beyond what is laid out above, it would need to be negotiated between everybody involved.

Note: In fields where lexicographic order is not used, the final author position also carries weight. It usually is the head of the research group or team that originated the project.