The only way I know of doing this is to find out which thread IDs map to which socket (or NUMA node). Once you have this information, you can use the usual thread-binding methods to enforce it.
If you're on Linux, you can use the numactl.h library to find out which hardware thread belongs on which NUMA node. Although a NUMA node isn't always one-to-one with a socket, it is the case for all post-Core 2 Xeons and all Opteron systems to date.
On Windows, you can use GetNumaNodeProcessorMask to figure out which hardware threads are on a node.
In the case where they don't map one-to-one (such as the Core 2 Xeons, where both sockets are on the same NUMA node), it probably won't matter anyway from a performance standpoint unless you're trying to micromanage the shared cache on each processor.