A light ray has an oscillating electric field associated with it, and this oscillating electric field will make electrons oscillate when the light ray passes through them. Note that I'm talking about light rays not photons - we'll get to photons in a bit.
When the oscillating field of the light makes electrons oscillate energy can be transferred between the light and the electrons. Describing exactly how this happens is somewhat involved so I'll gloss over the details. If you want to pursue this we describe the energy transfer using an equation called Fermi's Golden Rule.
Using Fermi's Golden Rule we find that the energy transfer is especially efficient when the frequency of the light matches the natural oscillation frequency of the electrons. For atoms there are a set of discrete oscillation frequencies and we get absorption of the light only when the frequency closely matches these atomic frequencies, and that's why atoms have a discrete spectrum.
If you're interested there is a truly wonderful description of how charge oscillates in an atom in Emilio's answer to Is there oscillating charge in a hydrogen atom?
So far so good, but in the photoelectric effect the energy transfer mechanism is a bit different. For the metals normally used in this type of experiment the electrons being ejected come from the conduction band of the metal, and these electrons are not bound to atoms. Instead they are delocalised over the while metal and behave very much like free electrons. Indeed, the electrons in the conduction band of a metal are often described using a model called the free electron gas. The way these electrons interact with light is more like electrons in a plasma than electrons in an atom.
Electrons in a metal (and a plasma) oscillate in response to the electric field of the light just as electrons in atoms do, and indeed we can get propagating oscillations called plasmons. However unlike a metal these don't have discrete oscillation frequencies but instead can have frequencies in a continuous range. This means light of any wavelength can interact strongly with the electrons, and consequently energy transfer between the light and the electrons is very efficient. This is, of course, why metals are opaque. They efficiently absorb energy from the light so the light can't pass through them.
Now we get onto photons. Light rays are not simply made up of photons like a hail of little balls of light. The relationship between a light ray and a photons is considerably more complicated than that. Indeed photons are more complicated things than you probably think. But when the oscillating electric field of the light exchanges energy with the oscillating electrons the energy is exchanged as a photon (or photons) and the photon energy exchanged is given by the well known formula $E=h\nu$.
If the energy of the photon is low the energy exchange will just create a plasmon that heads off into the metal and the energy eventually ends up as heat. However if the energy is high enough it spits out the electron as a photoelectron, and those are the photoelectrons we see in our experiment.
There is one last detail. The photoelectrons are preferentially scattered in the same direction as the light ray, so they travel down into the bulk of the metal and away from the surface:
We only see a photoelectron if our electron collides with another electron or nucleus in the metal and bounces back:
(images from my answer to Kinetic energy of photoelectrons)
This process is very inefficient and most of the photoelectrons don't make it out. The quantum efficiency of the process, i.e. the fraction of photoelectrons that make it out of the surface for us to measure, is only about one in $10^5$ to $10^6$.