It's late 12th-century England, sometime after 1176 but before 1189, so Henry II is king. A lay person is murdered inside a religious institution — monastery, abbey, something like that.
Who is responsible for investigating the crime?
Who is responsible for punishing the killer?
Does this change depending on whether the killer was a lay person or clergy?
Was this a clear demarkation that everyone knew and accepted, or was it open to argument?
Who is responsible for investigating the crime?
The person ultimately responsible would be the county sheriff, but their role was to manage the people beneath them, not so much to directly get involved in the investigation of crimes. Generally speaking, it fell on local people to investigate crimes and find those responsible. There were local officials called constables who investigated crimes, and every settlement was supposed to have one, but this was not a full time job nor were there any standards for how constables were to go about their job. It's also not clear how widespread constables actually were; it's one thing for the king to mandate that every settlement has one and quite another for there to actually be one available to everyone. No matter who has done the legwork of finding the suspect, the suspect would then either be left alone (for minor crimes) or detained (if they were seen as a threat, so a murderer would probably be locked up) until legal officials could gather to hold court and a make a judgement. These legal officials were known as 'itinerant justices', who would travel the country to hear cases from the local area. In theory, the court was supposed to only take a couple of weeks - a month at most - to get to you, but the logistics of travel and communication meant it could easily be far longer.
However, if the murder took place because of a land dispute, that would have to be heard at Westminster by a jury of twelve knights overseen by the central government, which only gathered seven times a year.
Who is responsible for punishing the killer?
This is where things start to get a little murky. In 1166, Henry II mandated that trials in England should include juries drawn from the local population and with people of roughly equivalent social standing. When the itinerant justices rolled into the area, they would meet with the sheriff, local bailiffs, and constables, then draw up a list of twelve locals from nearby towns to summon as a jury. At this point, the role of the jury was still a bit unclear. On paper, they were only supposed to report crimes, not actually judge them. So juries would determine whether to bring charges, but not actually whether they were guilty. If you're American, and familiar with the concept of a 'Grand Jury', much of that may be familiar to you because the modern Grand Jury is a direct descendant of this.
If the jury chose to bring charges, then the itinerant justices would coordinate with bailiffs to bring defendants to the location of the court, where the judge would conduct the trial and pass sentences. However, it was almost always the case that if a defendant was brought before a judge by the jury, then the defendant would be found guilty and punished because the jury had determined that they were most likely guilty of the crime, otherwise they wouldn't have brought charges against them in the first place. Judges tended to trust that juries had done their homework and accurately determined who was guilty and who was not, which made the jury de facto responsible for the determination of guilt, and the judge merely responsible for sentencing. Where there was dispute over whether a defendant was guilty, the goal was generally to persuade the jury that they were mistaken in accusing the defendant, rather than to persuade the judge, because if the jury changed its mind and went 'actually we aren't sure this guy is the criminal' then the trial would collapse. This was so common that by 1220 juries were formally responsible for the determination of guilt.
In any case, sentencing was the responsibility of the judge not the jury.
Does this change depending on whether the killer was a lay person or clergy? Was this a clear demarcation that everyone knew and accepted, or was it open to argument?
Oh boy, we are now firmly in murky territory. This was one of the major political issues of Henry II's reign, and the consequences of it are the thing Henry II is most known for. Henry II was adamant that clergy had to abide by the laws of the crown, and that it made no difference whatsoever if a defendant was a lay person or clergy. However, many English bishops were equally adamant that the church was independent from he crown and could conduct its own internal courts which ultimately answered to the pope rather than the king. Henry II saw this as a challenge to his power, whilst the English bishops saw it as affirming their rightful independence in line with papal doctrine.
When Henry II was beginning his legal reforms in the 1160s, archbishop Thomas Becket strongly opposed them. After a lot of pressure, he agreed to sign a document called the Constitutions of Clarendon, but fled before he could complete the paperwork to make it official. Becket was also the Lord Chancellor of England, so he was charged with failing to obey the king's edicts and found guilty as Becket fled to France. In 1170, a diplomatic solution was brokered by which Becket could return to England without facing criminal charges. But one of the first things he did when he got back was excommunicate several bishops for crowning Henry II's son as co-king in York. This was a breach of Canterbury's right to crown kings, and Becket was technically within his authority to do so, but it was clear that Becket did not accept Henry II's authority over these matters. I know we're diverging somewhat from the theoretical murder trial here, but this was still very much about whether clergy had to abide by the king's rules. Upon hearing of this, Henry II said something to the effect of "will nobody rid me of this turbulent priest?" (the actual words according to a contemporary were "What miserable drones and traitors have I nourished and brought up in my household, who let their lord be treated with such shameful contempt by a low-born cleric?", but that's not as snappy), and Becket was once again to be charged with contempt for the crown. Four knights and an unidentified clergyman went to detain him, but it's doubtful if their intentions were ever that peaceful. Predictably, Becket refused to cooperate and protested that clergy should not have to answer to the king. The knights briefly went outside, grabbed their weapons, declared Becket a traitor to the kingdom subject to summary execution, and murdered him on 29 December 1170.
So before 1170, there was substantial argument as to whether lay people and clergy should be subject to the same legal system. But after 1170, not so much. Henry was in charge and if you disagreed he was quite happy to have you killed.