It's... up to the GM.
I tried to address this issue in the broadest sense possible, to try and find some general rule or guideline that can be applied to any spell, instead of trying to ascertain it in a spell by spell basis.
In general, spells can be classified into two categories according to what they affect: a target, or an area.
For area spells, this is somewhat addressed in the CRB p.456, the section about area effects:
Many area effects describe only the effects on creatures in the area. The GM determines any effects to the environment and unattended objects.
This doesn't really tell us anything, it just leaves the work to GM. Under this rule, the same exact situation could be decided differently depending on the GM. One could rule that Burning Hands can light a torch, and the other that it can't, and both would be right.
For me, as a GM, this is a drawback as I like to rely on the rules as much as possible, and I can see several situations where this could lead to an argument with my players. But it's definitely better than the rules staying silent about it.
Now, about targeted spells, the situation is a bit different. According to the CRB p.304, the section about spell targets:
Some spells allow you to directly target a creature, an object, or something that fits a more specific category.
If you choose a target that isn’t valid, such as if you thought a vampire was a living creature and targeted it with a spell that can target only living creatures, your spell fails to target that creature.
The rules clearly make a distinction between creatures and objects, and they mention what happens if you choose an invalid target (albeit it is a bit unclear to me what "fails to target" means).
And some spells seem to follow this rule just fine, e.g. the spell Paralyze has a target of "1 creature", while the spell Shatter has a target of "1 unattended object", and the spell Hydraulic Push has a target of "1 creature or unattended object". So, clearly Paralyze can't target unattended objects, and Shatter can't target creatures, but Hydraulic Push can target both. And in this case it makes sense.
One could think this is all there is to it: for a spell to target an object it must explicitly indicate so. But this breaks immersion and seems really silly when you take into account several spells that perform an attack. Why would you be able to target a creature with those, but not an object? Take for example Acid Arrow, it has a target of "1 creature", but what it does is simply creating a magic arrow and shooting it to wherever you point, it would actually make sense to shoot it at an object if you wanted to.
This is, again, somewhat addressed in the GMG p.28, the section about adjudicating rules for players with "creative ideas" that fall out of the rules, as pointed out by ESCE in his answer:
Some of the most memorable moments come from situations that inherently call for a rules interpretation, like when a player wants to do something creative using the environment. The variety of these situations is limited only by the imagination of your players. It’s usually better to say “yes” than “no,” within reason. For example, [...] what about a player who wants to use a fire spell to deliberately ignite a barrel of oil? Surely that should have some effect!
This is where you can use a variant of the well-known improv “Yes, and,” technique: you can say “Yes, but.” With “Yes, but,” you allow the player’s creative idea, but tie it into the world and the game rules via some sort of additional consequences, potentially adding the uncertainty of an additional roll.
This basically acknowledges that casting a fire spell to ignite a barrel of oil is something outside of the rules but that would make sense, and then goes on to describe some optional house rule to handle this kind of situations. In one of the examples, it uses Produce Flame, a spell with a target of "1 creature", to attack a barrel, something not allowed by the rules:
Require a directed attack against an object, then allow foes to attempt saving throws against the object’s effect at a DC you choose. Example: cast a produce flame spell at a barrel of explosives.
Why this use of a spell is something out the scope of the rules is beyond my comprehension. In the end, the situation with targeted spells is very similar to that of area spells: when used against unattended objects, if the spell says nothing about it, it's up to the GM to work out some kind of house rule to make it work.