I think every DM-controlled creature is an NPC but is there a definition somewhere? Is an ooze an NPC? What about a dog or a golem? Does it need to be intelligent? Does it need to have class levels?
In the 3.5e Player's Handbook, in the Glossary, a NPC is defined as:
nonplayer character (NPC): A character controlled by the Dungeon Master rather than by one of the other players in a game session, as opposed to a player character.
character: A fictional individual within the confines of a fantasy game setting. The words “character” and “creature” are often used synonymously within these rules, since almost any creature could be a character within the game, and every character is a creature (as opposed to an object).
And of course
creature: A living or otherwise active being, not an object. The terms “creature” and “character” are sometimes used interchangeably.
It's therefore crystal clear RAW that a NPC is any active creature in the game's setting controlled by the DM instead of a player, from a cleric to a zombie to a dog to an animated candelabra.
The entirety of the DMG chapter 4 - Nonplayer Characters can help unpack this for you, it starts with the heading "Everyone in the World" and has sections for "Animals and Other Monsters," et al.
I prefer the definition by The Angry DM.
By all means go and read the full article, but it boils down to: Does it make decisions? Does it have goals? Is the DM actually role-playing it?
If a player controls it, it is a player character, and that's it. Even if it is a cohort, when the DM gives the control to player, it becomes a player character.
If the DM roleplays it, then it is an NPC. If no role-playing is involved, then no. This means that the prince who hires Player Characters may be an NPC, or may be just a scripted interface to a quest. A monster can be just a random encounter - or it can be a NPC, even if it never talks and attacks a PC on sight. What matters is - is it scripted? Or is there an actual character in the figure you present to your players? Does it make it's own choices, has it's own goals?
Edit for 3.5 DMG source: After phoning someone I know who collects the books like stray cats, he can confirm that in 3.5e chapter 4 is STILL the same chapter concerning NPCs. The quote from 3.5 is:
Its your job to portray everyone in the world who isn't a player character. NPCs run the gamut from the old woman who operates the livery to the foul necromancer out to destroy the kingdom to the dragon in its lair counting gold.
Further on the DMG also gives this definition:
An NPC with a hacking cough and strong opinions about the king is always more interesting that one you portray only as Kiale the 2nd level commoner. Remember that NPCs aren't just game statistics they are individuals with personalities, quircks and opnions. You should strive to make the NPCs in your game memorable character that the PCs will like or dislike.
The chapter then goes on the same way as the 5e one does - i.e. NPCs are only memorable characters worthy of note - not random encounters. They don't all need full stats. 3.5e does have more on followers and cohorts - there are full tables if you wanted actually levels to follow should you wish.
In short, 3.5e has MORE information on NPCs but they are all only named specials (not random encounters or chance encounters). They can have full on classes that arent available to PCs (such as adept, arisocrat, commoner) with skills, levels, BAB and saves of their own) or they can have simple descriptions if stats aren't necessary.
I would personally summarise all the above to say an NPC is a memorable entity, creature, person, animated thing that is supposed to be remembered by the party. It is always has a name and is worthy of inclusion in the adventure for a reason.
Is an ooze a NPC? Possibly, if it is a named special that will be roleplayed by the DM then yes. If it is a rolled encounter then no.
What about a dog or a golem? Same as the above. If you are familiar with the fallout series then "dogmeat" will certainly be classed as an NPC.
Does it need to be intelligent? Depends on your definition of intelligence. Monsters aren't necessarily intelligent but could be a role play worthy inclusion. A zombie that keeps appearing throughout your adventure and is roleplayed could be an NPC. "boss" kobolds that might want to cut a deal will be an NPC but can hardly be called intelligent. Red dragons on the otherhand...
Does it need to have class levels? Maybe. 3.5e has extensive tables for creating classes of NPCs but it also states that it could be a "memorable description with one or two outstanding traits". Describing a minstral playing in the corner of the room as being a bard with a scar and broken nose is better than saying "a minstral in the corner". That bard might only be a hook for an adventure so doesn't need full class levels but is a role played NPC with a name and purpose.