When a nail pops out of a wall, the cause is usually a framing member that has shrunk or expanded beneath the plasterboard. If the nail comes out easily when you pull on it with pliers, remove it and replace it with a larger nail. Otherwise, drive amother nail about 1.5 inches directly above or below it; then drive in the popped nail.
Use annular-ring or cement-coated nails. Press the plasterboard tightly against the framing as you hammer. Drive each nail flush with the wall; then in slightly, denting the surface with the hammer’s head. If the protruding nail is still not firmly seated, drive it in further, using a nailset. Fill each dent with joint compound and feather it into the surrounding area. Before painting, sand with fine paper, and prime.