In many energy-rechargeable wireless sensor networks, sensor nodes must both sense data from the environment, and cooperatively forward sensed data to data sinks. Both data sensing and data forwarding (including data transmission and reception) consume energy at sensor nodes. We present a distributed algorithm for optimal joint allocation of energy between sensing and communication at each node to maximize overall system utility (i.e., the aggregate amount of information received at the data sinks). We consider this problem in the context of wireless sensor networks with directional, non-steerable antennas. We first formulate a joint data-sensing and data-routing optimization problem with both per-node energy-expenditure constraints, and traditional flow routing/conservation constraints. We then simplify this problem by converting it to an equivalent routing problem, and present a distributed gradient-based algorithm that iteratively adjusts the per-node amount of energy allocated between sensing and communication to reach the system-wide optimum. We prove that our algorithm converges to the maximum system utility. We quantitatively demonstrate the energy balance achieved by this algorithm in a network of small, energy-constrained X-band radars, connected via point-to-point 802.11 links with non-steerable directional antennas.