I'd always thought there was some directive that stated this but apparently it's an urban myth, which makes sense because how would you ever enforce it were a manufacturer to pull out of a market such as Lancia in the early nineties or collapse like Saab did in early 2012.
There is some rumour of some EU based directive that suggests parts supply for ten years that isn't really enforceable but apparently that's just a rumour too.
Bear in mind that most motor manufacturers don't make the majority of their parts themselves but outsource manufacturing to companies such as Lucas, Bosch, Mann, Borg Warner, etc... Most of these manufacturers continue to make product available to both the dealership network and motorfactors for some years so it's incredibly rare that you'll find a mass-produced mainstream vehicle where spares aren't available from somewhere within the first few years of it's manufacture.
If there is a specific part you're struggling to obtain, consider getting in touch with the owners club for that vehicle as these organisations almost always will be able to help. Out of interest, what vehicle do you have and what part are you struggling to replace?