Disclaimer: the following may only apply in Spain.
Matrimonio is the most generic word of them. It can be used for both the ceremony and the couple (from the DRAE: "pareja unida en matrimonio"). You can see this fact in Ngram:
Nonetheless, matrimonio sounds a bit too formal for oral expression. It appears mostly in the written expression, and that's why it appears the most in Ngram.
Boda refers just to the ceremony. It is most used in oral expression, like:
Este fin de semana es la boda de mi hermana.
Casamiento is the same as boda, but it sounds odd to me. This is maybe the word that can suffer the most from regional differences, or even ethnical differences, because I can only remember a song that says:
Soy gitano y vengo a tu casamiento.
- "Soy gitano", by the Spanish cantaor Camarón de la Isla.
Nupcias is (again) the same as boda or casamiento, but it is more a kind of legal term, used only in expressions that note a second, third (and so on) marriage, like:
Juan y Maite se casaron en segundas nupcias.
meaning that for both of them it was the second time they got married. You can also say "Juan se casó en terceras nupcias con Maite", meaning that it was the third time that Juan got married. It can also be used in poetic contexts, such as the message in the invitations to the wedding:
Juan y Maite celebrarán sus nupcias en el Grand Hotel, se ruega confirmar asistencia.
On an aside note, it is interesting to see that de DRAE has a second meaning for "matrimonio" that reads: "En determinadas legislaciones, unión de dos personas del mismo sexo, concertada mediante ciertos ritos o formalidades legales, para establecer y mantener una comunidad de vida e intereses." The times, they are a-changin'...