As far as I know, both of these have a similar meaning. Are both interchangeable? In what situations would 変 be preferable over おかしい?
They are not as interchangeable as you might expect. I recommend sticking to 変 when you are going to express general "weirdness". 変 is somewhat broader to mean "inappropriately unusual", while おかしい is when the strangeness reminds of dysfunction of some sort.
This formula is...
Even when you can use both, 変 here means giving impression of strangeness or counterintuitivity, but doesn't (necessarily) imply logically wrong (=dysfunctional), while おかしい does.
"Don't do anything I wouldn't do."
In this case, what they advice against to do probably has some bad effect, but not necessarily out of insanity (maybe they just intend to do), thus おかしい is not likely used.