Some egos are so enormous, they take up the entire work space. If that ego belongs to the boss of the office, however, you may think you pretty much have to deal with it. Wrong. If your boss' ego is getting in the way of your productivity, there are ways of dealing with it that don't involve letting his ego swallow you whole.
Assess the Situation
Before doing anything, observe. Watch and see how the boss' ego is affecting productivity, whether yours or other employees in the workplace. Think about the behavior you consider egotistical, ensuring it's not behavior you're biased against and is truly disruptive behavior. See how other employees react to his ego. If they feel the same way about it as you, and their work suffers just as much if not worse, then you may be right to want to do something.
Speak With Him Privately
When you do talk to your boss, do so privately. Big egos feed off the presence of others, so confronting him in front of his peers isn't going to help matters, unless you like getting screamed at. Send him an email during quiet hours in the office and tell him you'd like to arrange a time to talk with him.
Insist on Proper Treatment
People with big egos tend to respect confidence in other people. If your boss' ego is causing him to treat you improperly, make a point early on to tell him you are not going to stand for behavior that causes your productivity to decline. Speak calmly and politely, but firmly and decisively.
Battle on Neutral Ground
Avoid threatening his ego. Knowingly attempting to one-up his ego by sharing knowledge in subjects he isn't familiar with or flaunting material possession he doesn't have will only lead to an ego war. Instead, try putting his guard down by reaching common ground on a subject, one in which competition isn't likely. Don't feed into the egomaniac's traps by reacting to it, instead simply redirect his attention to something else.