Regarding customs arriving from Canada, all the major Canadian airports have U.S. immigration and customs pre-clearance, meaning that you go through U.S. immigration and customs before you get on your plane in Canada.
U.S. immigration and customs pre-clearance is at Calgary, Edmonton, Halifax, Montreal, Ottawa, Toronto, Vancouver and Winnipeg.
Once you have arrived, you can take a cab or BART to San Francisco. Either will take you about 30 minutes. If there is traffic, a cab could take up to an hour.
So if you arrive at 3:15 PM (assuming you are on time), you should be able to get in your cab or in the BART train by 3:45 PM or 4 PM, at the latest.
That means you would be in downtown San Francisco by about 4:30 PM.
In order to be back in time for your 10:45 PM to SYD, you need to plan to be back at the terminal by 9:15 PM, so you should plan to leave S.F. by 8:30 PM.
That would still give you 4 hours in the city, which I think is plenty. You can easily get around by walking or taking the pretty good public transportation (muni trolleys, buses or the cable car).