You are thinking procedurally.
With SQL it's best to think in sets.
And you should also consider keeping the data normalized, so the need to update the balance is a bad idea, that should be queried when needed.
Database normalization - Wikipedia[
^]
Take a look at the following query and adjust as needed:
SELECT voteid
,allocation
,SUM(expenses) AS expenses
,allocation - SUM(expenses) AS Balance
FROM vote
JOIN expenditure ON vote.voteid = expenditure.voteid
GROUP BY voteid,allocation