Noel Carroll has an interesting discussion of the ethics of joking at The New Statesman. His point that the mere fact that you are joking sometimes does not provide a shield against moral criticism is surely right, but I think his argument is overly simplistic on a few points.
Carroll takes it that "I'm only joking" is supposed to work on the ground that jokes aren't assertions, so if, for instance, someone makes a racial joke, they aren't actually asserting the racial stereotype. I don't think this is right, and I think it's a case of something I've noted before, namely, philosophers overloading the act of assertion. The basic logical function of assertion is to put something on the 'premise board', so to speak; this is the minimal possible thing, and the most essential thing, that can be attributed to assertion, and everything else needs justification. The fundamental core of assertion is to propose something in such a way as to put it into play in reasoning. There is a tendency among philosophers to take assertion to pertain in some way to the 'really real', but, as I've noted before, there is nothing about the act itself that seems to require this. Given this, it seems entirely reasonable to say that at least many jokes involve assertions -- they are quite literally joking assertions.
Thus the real point seems to be that they are nonserious, that they are put forward in a deliberately absurd universe of discourse. Carroll responds to the "I'm joking" gambit, understood as nonassertion, by saying that the moral problem with jokes is not always focused on any purported assertion -- the suggestions, implications, etc., can be the problem. This is certainly true. But if "I'm joking" is put forward as clarifying that the universe of discourse was itself intended to be a universe of things to be treated as absurd, then we still don't have a reason why this would not be adequate.
Because (and this is something to which Carroll doesn't seem to give due weight) sometimes it is adequate. We do sometimes take "I'm joking" to make it all right. And there's another phenomenon that seems relevant here. I once had a Dutch professor who loved telling anti-Dutch jokes. (How do you make copper wire? Give one penny to two Dutchmen.) And you not uncommonly find black comedians telling racial jokes that could ruin the career of a white comedian who told them. For at least a very broad range of jokes, the same joke in different contexts is not subject to the same moral criticisms -- it matters who tells it, it matters where (church or a bar, for instance), it matters when, and so forth.
These points at least seem to suggest that the problem is not actually the content of the joke per se. Rather, the problem is when the joker is taking some kind of liberty to which he has no real right. Now, it seems fairly clear that our senses of exactly where to draw the lines differ quite a bit, and are often hazy, but everyone does seem to recognize this line of criticism sometimes. And it's why certain kinds of joke can be outright disrespectful in one context and perfectly fine in another.
I think there is a good argument that there are kinds of joking that can be said always to be wrong -- kinds of joking that are forms of actively humiliating a person or group, or deliberate ways to blaspheme. This does, I think, suggest that there are kinds of jokes that will only rarely if ever be acceptable; for instance, if people would have difficulty making sense of them unless they were understood to be put forward by one of these bad kinds of joking. But we do need to distinguish joking and the joke that is joked, if I may put it that way; how one handles the question of ethical criticism will depend on which is being considered.
Carroll recognizes the distinction (in his comments about joking being a performing art), but I think the distinction itself suggests that the "I'm just joking" gambit is not actually based on the assumptions about assertion he originally attributed to it. If we are considering the performance and not the script, it is the performing itself that is being criticized, and the script is itself only relevant to the extent that it provides insight into the performance. Consider, for instance, someone in a play playing a racist, doomed to comeuppance, who tells racist jokes. The actor is giving the script; but we recognize that his performance of it should not be conflated with that of an actual racist. If a villain in a story tells a blasphemous joke to mark his villainy, that's not in itself an act of blasphemy. We could still talk about whether it was appropriate, but there's an entirely different kind of inquiry than we would with just an ordinary blasphemer saying the same thing.
The other point at which I think Carroll's argument is a bit simplistic is in his discussion of the conditions of comic amusement. He says, "To make people laugh, a punchline must be free from anxiety or malice." But this seems quite clearly not the case.
We are perhaps here dealing with a problem that we can regularly find in aesthetic matters -- we lack a vocabulary adequate to what we are trying to say. The movie Ridicule is partly built on a distinction between vicious wit (associated with the French) and humor (associated with the English). Vicious wit is not necessarily anxiety-free or malice-free; its primary act is ridicule, and jokes of ridicule can perfectly well involve anxiety or malice. (They do not need to do so, but it takes a certain panache to ridicule without either anxiety or malice.) One could perhaps not include our response to this kind of joke under 'comic amusment', but then not all jokes exist to elicit comic amusement; on the other hand, if we include it, then it's not always true that the punchline must be free from anxiety or malice. His attempt, then, to argue that the morality and the comedy of a joke are not so distinct seems to amount to nothing more than saying that when malice would ruin the joke, it ruins the joke, and does not give (as his phrasing seems to imply) any general account for when this is the case.