Is it polite when my professor keep opening my office door without knocking at the door whenever he wants to ask anything?
Since the door closed, I am supposed to hear knock before breaking into, or rather, busting into the room. Is it polite?
It can be impolite -- from mild to severe --, but it really depends on the group culture.
For instance, my closer colleagues and I usually don't knock to each other's doors before entering -- the rare times the doors are closed --, and we've been doing this for more than 20 years: we used to have a common office space at the beginning of our careers and we simply grew up without any expectation of privacy at the workplace, and really we don't feel the need for it. I still share space with other colleagues or students.
I usually invite my PhD students not to knock when they have to visit me, and I usually don't knock on their doors.
In other groups, however, the above behaviour would be considered extremely impolite: if you are a newcomer, you should try to understand the prevailing group habits, but if you really find a certain habit annoying, try to approach the professor explaining -- in a non-confrontational way -- your concerns.
As others have said, this depends at least partially on the prevailing custom in the country or insitution you are in. Another factor which has not been mentioned so far is the number of people who use your office. It seems to me that the acceptability of entering an office (other than your own) without knocking increases with the number of people who occupy the office. If you are the sole occupant of the office, an unannounced visitor is more liable to threaten your sense of space than if your office is shared by several others, particularly if these other occupants also receive their share of visitors.
Indeed, if the office is shared by a large number of people, it may be preferred if visitors don't wait to be invited to 'come in!' as the duty of calling out such an invitation is liable to fall to the unfortunate person based closest to the door.
(As a footnote, I once shared an office with someone who was very senior and very respected in the department and who had just retired. I think I was his first office mate in over 30 years. Being a gentleman to his fingertips, he adopted the habit of knocking before entering our own office, a habit I then felt bound to adopt myself.)
I believe it is never polite to just walk into an office without making sure the occupants of the office are aware that they do not have an expectation of privacy. Many departments expect faculty to keep their doors open and in turn many PIs expect students to keep their doors open. Even where the department/lab culture accepts doors being shut, PIs often think of all space as "theirs" and expect unfettered access to their students. This does not make it right. A PI should discuss the policies with their students and hopefully come to a mutual agreement about privacy.
I was going to argue it depends since in my old department, graduate students used to be in a shared office that was the "gate keeper" to the laboratories. As it was on a noisy hallway, and there was valuable equipment in the office, the door was always kept shut, but not locked. No one knocked when opening the door. The reason that just walking in was not polite, is the PIs never discussed with my students that there was no expectation of privacy. While I think the students would have been hard pressed to change the minds of the PIs, the PIs should have explained the policies.