DirichletBC.apply will set the relevant diagonal entries to 1 and set off-diagonal entries on the same rows (across all blocks) to zero. This will correctly enforce the boundary conditions for the system of equations. You can use assemble_system instead of assemble if you wish to preserve symmetry.
Here is a complete python example implementing a simple PDE-constrained optimization problem. The problem is solved in one Newton iteration.
from dolfin import *
mesh = UnitSquareMesh(16,16)
a = Constant(1e-4)
V = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSpace([V, V, V])
bcs = [DirichletBC(W.sub(1), 0., "on_boundary"),
DirichletBC(W.sub(2), 0., "on_boundary")]
w = Function(W); u, y, p = split(w)
f = (1-y)**2 * dx + a * u**2 * dx
L = f + inner(grad(y), grad(p)) * dx - u * p * dx
dL = derivative(L, w)
H = derivative(dL, w)
u, y, p = w.split()
solve(H == -dL, w, bcs)