You can change between matrices and data frames easily. Working with a data frame will allow you to accomplish this easier with bracket notation:
bm <- as.data.frame(B) # assuming your matrix is called "B"
bm[,1:8] <- 0
bm[,9:56] <- 1
B2 <- as.matrix(bm)
Here's a full, working example with dummy data:
B = matrix(c(2:65), nrow=320, ncol=64) # Create a matrix with dummy data
bm <- as.data.frame(B) # Change it to a data frame
bm[,1:8] <- 0 # Change each row in the first 8 columns to 0
bm[,9:56] <- 1 # Change the rest to 1
B2 <- as.matrix(bm) # Change the data back to a matrix
Also, take a look at this post for how to properly post an R question. I'm honestly shocked your question hasn't been deleted or flagged yet. R on SO can be brutal.