A process that is carried out at the cellular level which results in the assembly, arrangement of constituent parts, or disassembly of a dendritic spine. A dendritic spine is a specialized protrusion from a neuronal dendrite and is involved in synaptic transmission.