The other answers already give excellent advice on how to get her attention. With this answer, I would like to give some background information that might be helpful to choose appropriate actions in this and similar situations.
TL;DR: There are different kinds of distance depending on occasion and relationship.
Distances in Man
Intimate Distance—Close Phase
This is the distance of love-making and wrestling, comforting and protecting. Physical contact or the high possibility of physical involvement is uppermost in the awareness of both persons.
Intimate Distance—Far Phase
(six to eighteen inches)
The use of intimate distance in public is not considered proper by adult, middle-class Americans even though their young may be observed intimately involved with each other in automobiles and on beaches.
Personal Distance—Close Phase
(one and a half to two and a half feet)
Where people stand in relation to each other signals their relationship, or how they feel toward each other, or both. A wife can stay inside the circle of her husband's close personal zone with impunity. For another woman to do so is an entirely different story.
Personal Distance—Far Phase
(two and a half to four feet)
Subjects of personal interest and involvement can be discussed at this distance.
Social Distance—Close Phase
(four to seven feet)
Impersonal business occurs at this distance, and in the close phase there is more involvement than in the distant phase. People who work together tend to use close social distance. It is also a very common distance for people who are attending a casual social gathering.
Social Distance—Far Phase
(seven to twelve feet)
Business and social discourse conducted at the far end of social distance has a more formal character than if it occurs inside the close phase. Desks in the offices of important people are large enough to hold visitors at the far phase of social distance. Even in an office with standard-size desks, the chair opposite is eight or nine feet away from the man behind the desk.
Public Distance—Close Phase
(twelve to twenty-five feet)
Linguists have observed that a careful choice of words and phrasing of sentences as well as grammatical or syntactic shifts occur at this distance. Martin Joos's choice of the term "formal style" is appropriately descriptive: "Formal texts . . . demand advance planning ... the speaker is correcfly said to think on his feet."
Public Distance—Far Phase
(twenty-five feet or more)
Thirty feet is the distance that is automatically set around important public figures. ... The usual public distance is not restricted to public figures but can be used by anyone on public occasions.
(These are excerpts from Edward T. Hall, The Hidden Dimension, Chapter X: Distances in Man. There is much more text regarding each kind of distance.)
Pulling her earphone out or patting her on the back, you enter intimate distance. This is reserved for very close people, like her boyfriend. Waving in front of her face is intimate or close personal distance.
At work you are probably expected to use at least social distance. So you can send a message, pass a note, wave across the cubicle, etc.
(There are some exceptions described in the book, e.g. elevators. Working together at the same computer might be another one.)
The given distances are not universal, but depend on culture (here: US) and subculture. As @Spehro Pefhany notes, there are notable systemic differences between city and rural folks, even within a culture. Both in the size of the bubble and how offended or threatened people feel if it is violated.
Distance is a form of nonverbal communication. Using intimate distance (like pulling her earphone out) might say that you are her boyfriend, or it might be interpreted as aggressive, or that there is a very good reason (like avoiding an accident).
For further reading I'd recommend "The Silent Language" and "The Hidden Dimension" by Hall. If you like science fiction, "Hellspark" by Janet Kagan is a good introduction.