Ostinato: Short phrase repeated identically (same pitch/rhythm) throughout a piece. Common in classical/Baroque music.
Riff: Short phrase repeated but varied in pitch/rhythm; often improvised. Common in jazz, blues, rock.
Key difference: ostinato is static repetition; riff is dynamic variation.