How to turn off all RAISE NOTICE on production server?
You could wrap them in an IF clause that tests a custom configuration variable. This will work but it's a bit verbose and each statement in PL/PgSQL has a cost.

I suspect you'll be better off lowering the log level in the RAISE messages so you log on a level like DEBUG that isn't captured by log_min_messages by default. That way you can just turn it on by changing client_min_messages or log_min_messages.

See the expanded form of the RAISE statement, eg:

RAISE DEBUG USING MESSAGE = 'TheMessage';


See the documentation for the RAISE statement.

Alternately, you can leave your messages at RAISE NOTICE and increase the log level, but that may hide other information you'll want to see in the logs. Better to log with a lower priority initially.

So long as the notices aren't doing lots of expensive string formatting or being called huge numbers of times I suspect you won't have too much trouble with their performance impact while logging to file/client is suppressed by log levels.