I have custom junction object which has Master-detail relation ship with contact. Generally we have relation ship field that contain contact name in junction object.but I want write soql query to fetch recods from child object where contact owner is 'ram'.
This page from the Force.com SOQL and SOSL Reference should help.
When you use a child-to-parent relationship, you can use dot notation:
SELECT Id, FirstName__c, Mother_of_Child__r.FirstName__c FROM Daughter__c WHERE Mother_of_Child__r.LastName__c LIKE 'C%'
In your case the
Mother_of_Child__r.LastName__c LIKE 'C%' would be something like
Contact__r.Owner.Name = 'ram' the Contact__r depends on the API Name of your relationship field.