How can an application (like Firefox) be forced to use a certain network interface?

Solution 1:

What you are looking for is a LS_PRELOAD shim, see Daniel Lange's blog entry for a detailed explanation and example code.

Solution 2:

You can use a more complex approach of connections marking and route policy.
It will work fine if you have a user that runs one software and anther.
This way you can mark the connections of one user and use specific routing table for it while all the others will use the default one.
The basic document to understand it all is at: http://www.lartc.org/lartc.html
Also an example for two connections you can see here: https://unix.stackexchange.com/questions/58635/iptables-set-mark-route-diferent-ports-through-different-interfaces
You can use the "owner" iptables module which will mark the connections to allow routing policy.