Can I use the distance between two objects to animate a property?
Yes, with Drivers

You can animate a property with a combination of values of other chosen properties.

To set up a Driver, just right click in the parameter field and choose "Add Driver"->"Manually create later" from the pop up menù. In the following example I added a "value" node and linked and added a driver to control it's value (the purple one), but I might have directly controlled the Size parameter of the Blur node itself:



In the Graph editor, under the Driver editor type, you can easily set up a Distance Driver Type and pick the two objects (camera and cube in the following example):



Here's the result: