I have searched an answer for this one and thr closest I could find was that when one means obligation in the past, one should use "had to" rather than "must have", and on the other hand, when a strong conviction or opinion is to be expressed, "must have" should be used, as in "He had to do it because he was charged with it, and "he must have seen her in the party because there is no way he wouldn't have seen her and gone to the party". I wonder if I can use "must have" to mean "will have had to" in the future. For example, is it grammatically correct to say "you must have finished your homework by the deadline or you will be expelled from the school.". If yes, can we use the same structure for the past events as in "he must have finished his homework or he would be expelled from the school".
"You must have finished your homework by the deadline or you will be expelled from the school."
Yes, this sentence is correct in the way you think it is. However, it sounds slightly dodgy to the ear because of the multiple ways "must have" can be used, so if one has a choice, I'd recommend something that doesn't employ the phrase.
I don't exactly understand your second sentence, but if you're trying to say that you have "deduced" that he has finished his homework (because otherwise he would have been expelled, which he is not) then you would say it like this to be unambiguous and grammatically correct:
"He must have finished his homework, because otherwise he would have been expelled from the school".