For example in a state where there are two ethnicities (or religions) forming half the population each, or one forming 75% and the other 25% (or any sizeable figure for both parties). Then there was a war and the winning side expelled the losing ethnic or religious group from the state.
This means I'm excluding ethnic/religious wars that resulted in partitions of a country.
Has this ever happened in recent history?
Oh goodness, yes. In population terms, some of the largest examples are central Europe during and after the Second World War, and the Indian subcontinent during and after partition. Very recently, the wars in the disintegrating former Yugoslavia were marked by terrifying ethnic cleansing, but that might be too recent for this sub. But you might be thinking of these already given that you are excluding "ethnic/religious wars that resulted in partitions of a country."
Still, the numbers of Germans, Poles, and others who moved or were forced to move with the shifting borders in 1945 was absolutely astounding. About twelve million ethnic Germans left or were expelled, and this following the death or dislocation of millions of people as a result of the national socialist state's invasion, terror, and genocide.
In the case of the subcontinent, as many as perhaps 13 million people moved during and after partition. By some reckonings it was the largest displacement of people in history.
There are dozens of smaller examples from the last century, including Palestine, Greece/Turkey, and Cyprus.
Some sources:
Demshuk, Andrew, The Lost German East: Forced Migration and the Politics of Memory, 1945–1970 (Cambridge University Press, 2012)
Jefferson, Steven, “Heimat, Space, Narrative: Toward a Transnational Approach to Flight and Expulsion” Journal of Contemporary European Studies 22, no. 4 (October 2, 2014) 523–25
Kaufmann, Chaim D, “When All Else Fails: Ethnic Population Transfers and Partitions in the Twentieth Century,” International Security 23, no. 2 (October 1, 1998) 120–56.
Khan, Yasmin, The Great Partition: The Making of India and Pakistan (Yale University Press, 2007)
Rieber, Alfred J. “Repressive Population Transfers in Central, Eastern and South‐Eastern Europe: A Historical Overview” Journal of Communist Studies and Transition Politics 16, no. 1–2 (March 1, 2000) 1–27