Short answer: you can't. There is no reliable rule that will cover all the various languages and exceptions and parents who name their daughter Maxwell and their son Andrea.
Longer answer:
The bad news is, the -a vs. -o ending rule has so many exceptions that it's useless. Bella is female, but Bela (well, technically Béla) is male; Andrea is male in Italy but female elsewhere; Luca is male in Serbia but female in Hungary; Consuelo is female; etc.
The good news is, there are some tools you can use.
- Some European countries publish lists of names that can be registered on birth certificates. Most of those lists are gender-specific, as in parents are not allowed to choose a masculine name for their daughter or vice-versa. Thus, if you know what country a person is from, you can look up their lists of registerable names and figure out the person's gender.
- An image search can sometimes be useful: plug in the given name and check if the pictures that come up are mostly men or mostly women.
- There are baby-name sites (or books) and gender-guesser websites that will give a gender for given names. Make sure to check a couple of different sites, though, because some of them can be very wrong.
However, the bottom line is that even after all your best efforts and web searches, you simply will not be 100% correct, because Parents Are Crazy. And they're increasingly getting crazier - in the US, even traditional masculine mainstays like Charlie are starting to skew female. So the only foolproof method to determine a person's gender is to ask.