Perception is for observation, Investigation is for deduction.
Some of this answer will be observations on how Wizards has done it so far and some of this will be logic, and some of it will be mechanics.
First for the headline question. It depends. when to use Investigation, and when to use Perception is not entirely clear yet, and I'm hoping we'll get more guidance in the DMG late this year. The guidance from the rules is that the two skills mostly seem to differ in the methods by which they are found.
Depending on the exercise, either, or both of the skills may be used.
For passive checks, you're almost always looking at Perception being the skill of record. While all skills can be used passively, some skills make more sense than others. Perception is the hallmark passive skill, whereas investigation makes less sense as a passive skill.
If the character is alert to the possibility of hidden objects/traps, but not actively searching, he's using passive perception.
The guidance for this seems to be (though we can't confirm yet), that the DC for actively looking for something is regularly about 5 less than the DC for passively looking for something (or sometimes actively looking always reveals it).
So here's how I would play it. Traps can be noticed with perception passively (usually DC 15). If the PC is looking, ask them how they are looking. If it's observational, then use Perception. If it's deductive, use Investigation. When they are searching for items, again, either skill is appropriate. This is somewhat counter to how WOTC has written adventures so far. They are always written to use perception to notice traps. Passive with a higher DC and active with a lower.
Investigation also has broader uses such as when you are trying to track clues, or put something together. It's also a great "roll for a hint" kind of skill if your PCs get stuck and need some help figuring out what to do next.
Note: I endorse Simanos's answer—especially as it covers flying, which is unreasonably and enormously complicated. However, as the question asks for a rules-as-written answer, this seemed relevant.
A creature can't intentionally fail a skill check, but a creature can try not to succeed on a skill check
I know that sounds like I'm splitting hairs, and, to a degree, I am, but choosing to fail isn't really a thing. When a creature has a choice whether to make a skill check, a creature can either make the skill check normally or not make the check. It takes a designer to step in and offer a third option: A creature can opt to give less than its all when making a skill check.
Sometimes a creature won't have the option to give less than its all—most skill checks made as reactions function in such a manner (for example, an attentive guard's Perception skill made in reaction to a ninja's Stealth skill check or a wary police detective's Sense Motive skill check made in reaction to a suspect's Bluff skill check). A creature can make the check more difficult for itself—perhaps by deliberately penalizing its Listen, Spot, or Perception skill checks with a cell phone, earplugs, a blindfold, or cologne, or deliberately penalizing its Sense Motive skill check by chugging booze and smoking hallucinogens—, but such measures are usually undertaken well before the check-that's-a-reaction is made and not something the creature can do in response to having to make—that is, in response to being forced by the game system to make—the skill check.
On the other hand, a skill check a creature can choose to make isn't failed by not making it. Instead, the skill check's result is unknown because the task remains untried. For example, if the GM says, "To reach the top of Mount Doom-doom-doom ('We're thrice doomed!'), Egaad the Unsturdy must make 279 successful Climb skill checks (DC 134)," Egaad's player can (and probably should) say, "That's stupid, and Egaad's not doing that," and Egaad'll suffer the consequences—if any—for his choice. That's not failing 279 Climb skill checks (which, if it were, would suck and be weird); instead, that's just not making a ridiculous number of Climb skill checks.
But between those extremes, at least one of the game's designers allows more granularity than just the bog standard of roll, take 10, and take 20. In the Dragon #311 Dungeoncraft column "Dungeon Adventure, Part III: The Inhabitants," Monte Cook includes this sidebar:
Taking 0
…An NPC guard makes a Listen check because he's on duty, alert, and expecting trouble, but what about NPCs who are not alert? What about a room full of bandits playing cards? Surely they don't deserve the same kind of Listen check as the alert guard.
To simulate this, you can assume that all guards take 10 on their Listen checks and that other inhabitants who are not actively being "alert" take 0. "Taking 0" is just like taking 10. You assume that the character taking 0 got a 0 result on the die because he wasn't even trying. However, when the DC is low, or when skill bonuses are high, taking 0 can still result in a lot of success. It allows you [the DM] to determine at which point someone who isn't paying any attention might still hear something (or Spot something).
You can do something similar with sleeping characters, but instead of taking 0, they take −10. (97)
Emphasis mine. (For context, Monte Cook is one of the authors of Dungeons and Dragons, Third Edition—specifically, he gets the primary writing credit for the Dungeon Master's Guide (2000)—, and that's the game upon which the Dungeons and Dragons 3.5 revision is based and that's the game upon which Pathfinder is based.)
So while this sidebar concerns itself primarily with on- and off-duty guards making Listen checks, the idea of taking 0 ("Meh") or even taking −10 ("I can do this in my sleep!") is endorsed by one of the game's designers. And, by extension, a generous GM could rule that a creature could take even less than −10, instead taking −20 ("I could do this dead!") or even taking −30 ("I could do this if I never existed!" …or something). By the same token, a GM can rule that a creature deliberately opting to make a skill check by rolling the die can further opt not to try and suffer a −10 penalty (or worse) on the check.
Thus a creature that chooses to make a skill check at all can't intentionally and absolutely fail the skill check, but the GM may allow the creature making such a check to put forth so so little effort that a result of less than the necessary DC is nearly guaranteed, which, in the end, will look to outsiders a whole lot like intentional failure.
Best Answer
When certain spells or other game effects request skill-less checks
As pointed out by Someone_Evil, certain spells, such as entangle, dispel magic, telekinesis, etc, require ability checks to use or escape them, and these ability checks do not specify a skill.
Dispel magic:
Entangle:
Telekinesis:
When rolling Initiative to determine your order in combat
There's also Initiative rolls (thanks Greenstone Walker), which is technically a Dexterity ability check, although because it has it's own name ("Initiative"), it's often not called that. Initiative is described in the basic rules under the Order of Combat section:
Although you cannot add your proficiency bonus to it, there are other bonuses you can add to it.
When you make an ability check using a tool proficiency
As pointed out by V2Blast, "ability checks relating to a tool do not have any skill associated with them, because whether you add your proficiency bonus to the roll simply depends on whether you're proficient with the given tool. The most obvious example in the rules is thieves' tools, which you can use to make a Dexterity check to pick a lock/disarm a trap; that's not associated with any skill, but you can still add your proficiency bonus depending on whether you're proficient with the tool."
From the basic rules on Tools:
In other words, using a tool you're proficient with is just an alternative way to add your proficiency bonus vs. making a skill check. Either way, it will be a kind of ability check that uses one of your six ability scores (but not necessarily always the same one, as mentioned in the above quote) and optionally your proficiency bonus if you're using a skill or tool set that you're proficient with.
When the DM otherwise decides that none of the existing skill or tool proficiencies apply to the particular check
Without wanting this to turn into a list of every example I can think of, basically, when there are situations that call for an ability check, using one of the 6 ability scores, but the nature of the check doesn't really relate to a specific skill (or tool set, as per the above section).
In such scenarios the DM would ask for an "Intelligence check", for example, rather than, say, "Intelligence (History)" (or more commonly just "History"). In practice, associating an ability check with a skill just allows the player to be able to add their proficiency bonus if they are proficient in that skill, so an ability check without an associated skill (or tool) simply wouldn't include your proficiency bonus.
As an example that I've seen other DMs use, a DM might ask for an Intelligence check to see if your character can remember something that happened last week. Of the five skills normally associated with Intelligence (Arcana, History, Investigation, Nature, Religion), none of those really apply (History is the closest, but that's more to do with having studied history, not simply remembering something from the recent past).
Another example that I've seen is whether a not very intelligent character can think of a plan that the player (who is more intelligent that their INT 8 character) has thought of, to see if that character was able to have the brainwave necessary to think of it. These sorts of ability checks can literally be as arbitrary as that, depending on the DM.