What is the best way to express my condolence to a professor?
If you found this information online then it’s hardly an invasion of privacy (unless of course you hacked his email or something). I wouldn’t worry about that. 

If there is a public announcement (an obituary) of a religious service (eg a wake or a shiv’a), you can probably attend as these things are usually open to the public for exactly people like you- distant relatives or acquaintances who wish to comfort the grieving family. For example, if they’re Jewish, it’s customary to bring some simple baked goods (say, cookies) since the family is hosting a seven-day event. I’m not familiar with grieving customs in other religions but that should be easy enough to find out. In these situations your professor would most likely greatly appreciate your presence and the gesture. 

If there’s no public announcement then wait for the professor to come back to the university and try to catch them in person to offer your condolences. Again, the gesture would be greatly appreciated I believe.

My condolences...