What you need to do is use Action support on your input field. On change of your input field will fire the controller method which will populate the lookup flied querying the data from database.
<apex:page controller="MyCustomController">
<apex:form id="myForm">
<apex:pageBlock title="Sample">
<apex:pageBlockSection>
<apex:inputField value="{!acc.type}" >
<apex:actionSupport action="{!populateParentAccount}" event="onchange" reRender="myForm"/>
</apex:inputField>
<apex:inputField value="{!acc.ParentID}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller code is simple.
public class MyCustomController{
public Account acc{get;set;}
public MyCustomController(){
acc=new Account();
}
public void saveAccount(){
upsert acc;
}
public void populateParentAccount(){
if(this.acc.Type=='Other')
acc.ParentID=[Select id from account where name='ACC'][0].id;
}
}
The magic here happens at action support which on change of type calls populateParentAccount which populates the value of parentID in account instance.
Now comes the role of rerender tag, which reflects the newly populated value onto page.