Is there a term for reversing phrases, usually for comedic effect?

I think the word you're looking for is either "chiasmus" or "antimetabole": Chiasmus Definition

Karl Marx was fond of using it, e.g.

"Herr Szeliga makes mysteries out of real trivialities. His art is not that of disclosing what is hidden, but of hiding what is disclosed."

https://www.marxists.org/archive/marx/works/1845/holy-family/ch05.htm~

"The weapon of criticism cannot, of course, replace criticism by weapons"

https://www.marxists.org/archive/marx/works/1844/df-jahrbucher/law-abs.htm

"It is not the consciousness of men that determines their existence, but their social existence that determines their consciousness."

https://www.marxists.org/archive/marx/works/1859/critique-pol-economy/preface.htm


As a term for a type of humor I can't think of it but is could simply be called a "Reversal". Such reversal of ideas or phrases often invite humor or nearly so. Knowing that the grass is always greener on the other side my neighbor spends the afternoons in my yard. Some people make pot roast, I make roast pot. The laughs keep on coming but only just.

If it must be a clever term then perhaps "Switcheroo". Disputes over its true meaning lends itself to innumerable bits of its own.