I'm going to Australia next October and I was wondering if it is safe to go diving (near Cairns) even though it will be my first time doing so. Should I take a course locally before the trip?
Safe, absolutely! Diving in Australia is some of the safest in the world.
Sensible use of your time on holiday? Perhaps not... I'd suggest that you'd want to do the theory part at home before you go. That way the two days sat inside happen when you're not on holiday. When you get out there, do the open water parts of the qualification as part of your diving experience there.
One possible reason though for learning before you go is so you can get a few extra dives in at home. Some dives in Australia will require some level of experience, and they'll be quite strict on that. If you've only just qualified, you may not be able to do all of the different dive sites (though there will be plenty around Cairns you can do!)
A bit cold currently to consider diving there, isn't it?
There are tons of PADI-certified operators in Cairns that offer day trips or a week-long pass aboard their vessels. We used Tusa Dive. Apparently, they offer maximum flexibility in the reef choice, considering visibility and safety.