While this may not be what you were hoping to hear, the answer is: it really all depends on the context. That said, I think this word "context" gets used very broadly in situations like this - the reality is that some of that "context" is word knowledge and common sense. Let's look at some of your examples:
暇ですか?
is almost certainly about someone else, because you know whether or not you are free - in essence that's a decision you make. It would be bizarre to ask someone else.
頭がいいですか
is again overwhelmingly more likely to refer to someone else. The reason here is a little more difficult to pin down, but I would say it boils down to the fact that it's very weird to ask someone else to determine ground truths about your own intelligence. Even in English, Am I smart?
strikes me as a bizarre question. Note that if it were intended to be rhetorical, Japanese has other mechanisms used to make that explicit like かな
.
Now, conversely, if you ask 頭がいいと思いますか?
this could easily be a question about whether the other person thinks you are smart. It could of course also be a question about whether the other person thinks they are smart; this is one of those cases where context really will make the decision. In a vacuum though, I would assume this meant Do you think I'm smart?
.
There are always ways to make things ambiguous, though. If you are in a group of three and someone asks 暇ですか?
, it would be perfectly appropriate for you to clarify who they were asking about with something like 私ですか
or 私がですか?
.
Also while you likely wouldn't use the word 暇
in this case, it is conceivable that you could be asking someone else about whether you were free in a sentence like
日曜日は空いてますか?
If that person managed your calendar, and you were talking about your calendar.