To your close friends or someone younger
To someone in a higher position / acquaintance
Until what time can we use it?
I would say until 10 a.m. In my opinion, おはよう at 11 a.m. sounds strange. Let’s see the reason why I feel that way.
おはよう comes from i adjective 早い (はやい・hayai) which means early.
お is a polite way if you add it before a noun (it does not apply to all nouns.)
ございます is one of the formal ways to say ある or いる. It is more formal than あります or います.
The sentence ‘おはようございます。’ means ‘You are active early!’, and it became one of the greetings. Always the subject of the sentence is ‘You’, so to respect others, ‘お’ at the beginning is a must.