This might be a misunderstanding. Autocommit doesn't seem to be the problem.
The function body is a string, you need to quote it. Typically you would use dollar-quoting to make your live easier:
CREATE FUNCTION test_trigger()
RETURNS trigger AS
$func$
BEGIN
IF () THEN INSERT INTO...;
ELSEIF ()...;
...
...
END IF;
RETURN NULL;
END
$func$ LANGUAGE plpgsql;
Apart from that, to "disable" autocommit, start a transaction. That's what the suggested solution in your last line aims for:
BEGIN; -- starts transaction
UPDATE tbl ...; -- not commited yet
CREATE FUNCTION ...; -- not commited yet
COMMIT; -- *now* we commit