Moral dilemma in unwittingly being paid to complete a student's work I am a computer science freelancer who takes on medium-sized projects I can complete in a month or less. I was approached by someone who wanted a set of 12 tutorials at least 500 words each about certain programming topics with code examples and workouts. We talked payment and I accepted this project and got to work. I have been using GitHub to write the pieces and publish them privately on my account. 

Here's where things get tricky. After I had completed the tutorials, but before I sent them to him, he disclosed to me his full name and the institution that he attends. It turns out that this was his honors project for an undergraduate major in Computer Science. He has already paid me.

My dilemma is this: I would like to return his money and not send him the tutorials and have him fail his school project. However, I have worked on this for 3 weeks, and I obviously need the money.

In our original conversation, he made no such mentions of secrecy, so at the very least I could make the GitHub repository public and still accept his payment.

My question is this: What is my best course of action? I don't want him to submit that work as his own. However, I still would like to get paid as he did not confine to me he was planning on plagiarism until the very end.
I think you should take the money, try to retain as much of my copyrights as possible (the law may help you do this implicitly rather than explicitly, which may be helpful), and refrain from doing anything else until after the student misuses your work.
Why? Consider that:

Plagiarism is not a crime.
Copyright violation is a crime.
Neither has occurred yet.
You have done the work in good faith.
You are not responsible for preventing others from plagiarizing your work.

Refunding him and keeping the work would be unfair to you because you have already done the work. You have every right to keep the money for the work you have done.
Refunding him and keeping the work would be unfair to him too, since he has every right to obtain the work from you that he has paid you for and waited for. Even if you refund his money, you can't refund the time that he has spent waiting for you to do the work, so you would arguably be liable for damages too.
If your work is actually plagiarized, then you will have a basis for complaining academically and/or legally, and it will be more difficult for your client to view you as a &quot;snitch&quot;, etc. if he violates your copyright.
If you let his institution know before the deed occurs, then I'd argue you're doing something morally wrong: you're getting him into trouble for an act that he has not even committed yet. (This might be fine for dangerous actions, but this isn't one.)

Clarification:
I should clarify that my answer is only intended for a &quot;generic&quot; freelancer, not someone who has something else at stake too.  For example, if you yourself were e.g. a professor/graduate student/public figure/etc., then you could earn yourself a bad reputation among your colleagues by giving him the work even if most other people would consider what you do to be entirely ethical/moral/righteous. In that case, the wisest career move for you may not be the same thing as what a typical freelancer might or should do, so keep in mind I'm not addressing such situations.