Silence calls from everyone but a defined set of numbers?

If I'm on-call, I only want to be woken by important calls or text messages. How can I set up an iPhone to ring during certain hours only for calls or texts from a certain set of numbers?

If it can't be done using vanilla iPhone apps, is there a 3rd party app that could do it?

You could make a silent ringtone your default, and then assign other custom ringtones to each of that certain set of numbers.

See Apple's Purchasing and creating ringtones FAQ for a start.

2016
This has changed significantly recently - posting this with iOS 10, but I think was available from 9, maybe 8

Settings > Do Not Disturb

You can set a defined daily schedule
This can also be toggled from the lockscreen, on an ad-hoc basis

Settings > Do Not Disturb > Allow Calls From >

You can choose by many criteria, Everyone, No-One, Favourites... or any specific group from Contacts

Silence calls from everyone but a defined set of numbers?

If you jailbreak, of course there's an app for that, several in fact. Search for "blacklist".