This can be preference but the pros advice painting trim before walls. It is easier to apply the painters tape along the trim work for a cleaner wall line than doing it the other way around.